]> Creatis software - crea.git/blob - cmake/CREAMacro_AddLibrary.cmake
9ce9a407e5c28240470a162efb26637a2243df47
[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 #
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 # Creates and installs a library
26 # Uses CREA_DYNAMIC_LIBRARY_EXPORT and CREA_INSTALL_LIBRARY
27 # hence the variables to be set for these are needed 
28 # Additionnaly one needs to set :
29 # ${LIBRARY_NAME}_HEADERS : the list of headers to install
30 # ${LIBRARY_NAME}_SOURCES : the list of files to compile to build the lib
31 # ${LIBRARY_NAME}_LINK_LIBRARIES : the list of libs to link with
32 MACRO(CREA_ADD_LIBRARY LIBRARY_NAME)
33
34   IF(CREA_VERBOSE_CMAKE)
35     MESSAGE(STATUS "===============================================")
36     MESSAGE(STATUS "Configuring library ${LIBRARY_NAME}")
37     MESSAGE(STATUS "   Headers  : ${${LIBRARY_NAME}_HEADERS}")
38     MESSAGE(STATUS "   Sources  : ${${LIBRARY_NAME}_SOURCES}")
39     MESSAGE(STATUS "   Link libs: ${${LIBRARY_NAME}_LINK_LIBRARIES}")
40     MESSAGE(STATUS "===============================================")
41   ENDIF(CREA_VERBOSE_CMAKE)
42
43
44   # MANAGE SHARED LIB
45   CREA_DYNAMIC_LIBRARY_EXPORT_OPTION(${LIBRARY_NAME})
46
47   # CREATE THE TARGET
48   ADD_LIBRARY(${LIBRARY_NAME} ${${LIBRARY_NAME}_SHARED} ${${LIBRARY_NAME}_SOURCES})
49
50   # LINK
51   TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${${LIBRARY_NAME}_LINK_LIBRARIES})
52
53   # INSTALLS LIBRARY FOR CMAKE
54   CREA_INSTALL_LIBRARY_FOR_CMAKE(${LIBRARY_NAME})
55
56   # INSTALLS LIBRARY
57   INSTALL(
58     FILES ${${LIBRARY_NAME}_HEADERS}
59     DESTINATION ${${LIBRARY_NAME}_INSTALL_TREE_RELATIVE_INCLUDE_PATHS}
60     )  
61
62 IF(WIN32)       
63   INSTALL(
64     TARGETS ${LIBRARY_NAME}
65     DESTINATION bin)
66 ELSE(WIN32)
67   INSTALL(
68     TARGETS ${LIBRARY_NAME}
69     DESTINATION ${CMAKE_CREA_LIB_PATH} )
70 ENDIF(WIN32)
71
72 #EED 01/July/2011
73 IF (UNIX)
74   add_definitions(-fPIC)
75 ENDIF(UNIX)
76
77
78 ENDMACRO(CREA_ADD_LIBRARY)