]> Creatis software - crea.git/blob - cmake/CREAMacro_AddExecutable.cmake
761b3d8c9f9dce2960666915cde6b008c3742454
[crea.git] / cmake / CREAMacro_AddExecutable.cmake
1 # ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
4 #                        pour la Santé)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 #
7 #  This software is governed by the CeCILL-B license under French law and 
8 #  abiding by the rules of distribution of free software. You can  use, 
9 #  modify and/ or redistribute the software under the terms of the CeCILL-B 
10 #  license as circulated by CEA, CNRS and INRIA at the following URL 
11 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
12 #  or in the file LICENSE.txt.
13 #
14 #  As a counterpart to the access to the source code and  rights to copy,
15 #  modify and redistribute granted by the license, users are provided only
16 #  with a limited warranty  and the software's author,  the holder of the
17 #  economic rights,  and the successive licensors  have only  limited
18 #  liability. 
19 #
20 #  The fact that you are presently reading this means that you have had
21 #  knowledge of the CeCILL-B license and that you accept its terms.
22 # ------------------------------------------------------------------------ */ 
23
24
25 #Generates the cmake commands to build and install the executable EXE_NAME.
26 # ${EXE_NAME}_SOURCES        must contain the list of files to compile 
27 #                            to build the executable.
28 # ${EXE_NAME}_LINK_LIBRARIES must contain the list of libraries to link with
29 #
30 # On Windows:
31 # if ${EXE_NAME}_HAS_GUI is set to TRUE then a Win32 application is generated
32 # if ${EXE_NAME}_CONSOLE is set to TRUE then the application will have a console attached.
33 MACRO(CREA_ADD_EXECUTABLE EXE_NAME)
34
35   IF(CREA_VERBOSE_CMAKE)
36     MESSAGE(STATUS "===============================================")
37     MESSAGE(STATUS "Configuring executable ${EXE_NAME}")
38     MESSAGE(STATUS "   Sources  : ${${EXE_NAME}_SOURCES}")
39     MESSAGE(STATUS "   Link libs: ${${EXE_NAME}_LINK_LIBRARIES}")
40     IF(WIN32)
41       MESSAGE(STATUS "   Win32 app: ${${EXE_NAME}_HAS_GUI}")
42       MESSAGE(STATUS "   Console  : ${${EXE_NAME}_CONSOLE}")
43     ENDIF(WIN32)
44     MESSAGE(STATUS "===============================================")
45   ENDIF(CREA_VERBOSE_CMAKE)
46
47   IF(WIN32 AND ${EXE_NAME}_HAS_GUI )
48     ADD_EXECUTABLE(${EXE_NAME} WIN32 ${${EXE_NAME}_SOURCES})
49     IF( ${${EXE_NAME}_CONSOLE} )
50       SET_TARGET_PROPERTIES(${EXE_NAME} PROPERTIES LINK_FLAGS /subsystem:console )
51     ENDIF( ${${EXE_NAME}_CONSOLE} )
52   ELSE(WIN32 AND ${EXE_NAME}_HAS_GUI )
53     IF(${EXE_NAME}_HAS_GUI AND APPLE)
54       ADD_EXECUTABLE(${EXE_NAME} MACOSX_BUNDLE ${${EXE_NAME}_SOURCES})
55     ELSE(${EXE_NAME}_HAS_GUI AND APPLE)
56       ADD_EXECUTABLE(${EXE_NAME}  ${${EXE_NAME}_SOURCES})
57     ENDIF(${EXE_NAME}_HAS_GUI AND APPLE)
58   ENDIF(WIN32 AND ${EXE_NAME}_HAS_GUI )
59   
60   TARGET_LINK_LIBRARIES(${EXE_NAME} ${${EXE_NAME}_LINK_LIBRARIES})
61
62   INSTALL_TARGETS(/bin/ ${EXE_NAME})
63
64 ENDMACRO(CREA_ADD_EXECUTABLE)
65
66