]> Creatis software - crea.git/blob - cmake/CREAMacro_AddLibrary.cmake
#3180 crea Feature New Normal Future - Set wx-config for wxWidgets 2.8
[crea.git] / cmake / CREAMacro_AddLibrary.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 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and 
10 #  abiding by the rules of distribution of free software. You can  use, 
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B 
12 #  license as circulated by CEA, CNRS and INRIA at the following URL 
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability. 
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */ 
25
26
27 # Creates and installs a library
28 # Uses CREA_DYNAMIC_LIBRARY_EXPORT and CREA_INSTALL_LIBRARY
29 # hence the variables to be set for these are needed 
30 # Additionnaly one needs to set :
31 # ${LIBRARY_NAME}_HEADERS : the list of headers to install
32 # ${LIBRARY_NAME}_SOURCES : the list of files to compile to build the lib
33 # ${LIBRARY_NAME}_LINK_LIBRARIES : the list of libs to link with
34 MACRO(CREA_ADD_LIBRARY LIBRARY_NAME)
35
36   IF(CREA_VERBOSE_CMAKE)
37     MESSAGE(STATUS "===============================================")
38     MESSAGE(STATUS "Configuring library ${LIBRARY_NAME}")
39     MESSAGE(STATUS "   Headers  : ${${LIBRARY_NAME}_HEADERS}")
40     MESSAGE(STATUS "   Sources  : ${${LIBRARY_NAME}_SOURCES}")
41     MESSAGE(STATUS "   Link libs: ${${LIBRARY_NAME}_LINK_LIBRARIES}")
42     MESSAGE(STATUS "===============================================")
43   ENDIF(CREA_VERBOSE_CMAKE)
44
45
46   # MANAGE SHARED LIB
47   CREA_DYNAMIC_LIBRARY_EXPORT_OPTION(${LIBRARY_NAME})
48
49   # CREATE THE TARGET
50   ADD_LIBRARY(${LIBRARY_NAME} ${${LIBRARY_NAME}_SHARED} ${${LIBRARY_NAME}_SOURCES})
51
52   # LINK
53   TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${${LIBRARY_NAME}_LINK_LIBRARIES})
54
55   # INSTALLS LIBRARY FOR CMAKE
56   CREA_INSTALL_LIBRARY_FOR_CMAKE(${LIBRARY_NAME})
57
58   # INSTALLS LIBRARY
59   INSTALL(
60     FILES ${${LIBRARY_NAME}_HEADERS}
61     DESTINATION ${${LIBRARY_NAME}_INSTALL_TREE_RELATIVE_INCLUDE_PATHS}
62     )  
63
64 IF(WIN32)       
65   INSTALL(
66     TARGETS ${LIBRARY_NAME}
67     DESTINATION bin)
68 ELSE(WIN32)
69   INSTALL(
70     TARGETS ${LIBRARY_NAME}
71     DESTINATION ${CMAKE_CREA_LIB_PATH} )
72 ENDIF(WIN32)
73
74 #EED 01/July/2011
75 IF (UNIX)
76   add_definitions(-fPIC)
77 ENDIF(UNIX)
78
79
80 ENDMACRO(CREA_ADD_LIBRARY)