]> Creatis software - crea.git/blob - cmake/CREAMacro_ManageSharedLibrary.cmake
bd4032c0f475eab6708aab0e1eae606302151ac0
[crea.git] / cmake / CREAMacro_ManageSharedLibrary.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 # Manages the shared library creation/use 
26 # * Creates an option ${LIBRARY_NAME}_BUILD_SHARED 
27 # * Generates the file ${LIBRARY_NAME}DLLImportExport.h which 
28 #   defines the symbols ${LIBRARY_NAME}_EXPORT and ${LIBRARY_NAME}_CDECL
29 #   to be used in exported classes/functions declarations
30 MACRO(CREA_MANAGE_SHARED_LIBRARY LIBRARY_NAME)
31
32   # STATIC OR DYNAMIC (SHARED) ? 
33   OPTION( ${LIBRARY_NAME}_BUILD_SHARED  
34   #JPR 8 Avr 2011 ON-> OFF, to avoid troubles with unaware users
35     "Build ${LIBRARY_NAME} as a shared library (dynamic) ?" OFF)
36   IF (${LIBRARY_NAME}_BUILD_SHARED)
37     SET(${LIBRARY_NAME}_SHARED SHARED)
38     CREA_DEFINE(${LIBRARY_NAME}_BUILD_SHARED)
39   ENDIF(${LIBRARY_NAME}_BUILD_SHARED)
40   
41   CREA_DEFINE(${LIBRARY_NAME}_EXPORT_SYMBOLS)
42
43   # ADDS CURRENT BINARY DIR TO INCLUDE DIRS
44   INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
45
46   # CONFIGURES ${LIBRARY_NAME}DLLImportExport.h
47   CONFIGURE_FILE(
48     ${CREA_CMAKE_DIR}/LIBRARY_NAMEDLLImportExport.h.in
49     ${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME}DLLImportExport.h
50     @ONLY IMMEDIATE
51     )
52   # ADDS IT TO THE LIST OF HEADERS
53   SET(${LIBRARY_NAME}_HEADERS
54     ${${LIBRARY_NAME}_HEADERS}
55     ${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME}DLLImportExport.h
56     )
57   
58
59 ENDMACRO(CREA_MANAGE_SHARED_LIBRARY LIBRARY_NAME)
60