]> Creatis software - crea.git/blob - cmake/CREAMacro_DynamicLibraryExport.cmake
#3180 crea Feature New Normal Future - Set wx-config for wxWidgets 2.8
[crea.git] / cmake / CREAMacro_DynamicLibraryExport.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 # Manages the shared library creation/use 
28 # * Creates an option ${LIBRARY_NAME}_BUILD_SHARED 
29 # * Generates the file ${LIBRARY_NAME}_EXPORT.h which 
30 #   defines the symbols ${LIBRARY_NAME}_EXPORT and ${LIBRARY_NAME}_CDECL
31 #   to be used in exported classes/functions declarations
32 MACRO(CREA_DYNAMIC_LIBRARY_EXPORT_OPTION LIBRARY_NAME)
33
34   # STATIC OR DYNAMIC (SHARED) ? 
35   OPTION( ${LIBRARY_NAME}_BUILD_SHARED 
36   #JPR 8 Avr 2011 ON-> OFF, to avoid troubles with unaware users
37     "Build ${LIBRARY_NAME} as a shared library ( i.e. dynamic) ?" OFF)
38   IF (${LIBRARY_NAME}_BUILD_SHARED)
39     SET(${LIBRARY_NAME}_SHARED SHARED)
40     CREA_DEFINE(${LIBRARY_NAME}_BUILD_SHARED)
41   ENDIF(${LIBRARY_NAME}_BUILD_SHARED)
42   
43   CREA_DEFINE(${LIBRARY_NAME}_EXPORT_SYMBOLS)
44
45   # ADDS CURRENT BINARY DIR TO INCLUDE DIRS
46   INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
47
48   # CONFIGURES ${LIBRARY_NAME}_EXPORT.h
49   CONFIGURE_FILE(
50     ${CREA_CMAKE_DIR}/LIBRARY_NAME_EXPORT.h.in
51     ${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME}_EXPORT.h
52     @ONLY IMMEDIATE
53     )
54   # ADDS IT TO THE LIST OF HEADERS
55   SET(${LIBRARY_NAME}_HEADERS
56     ${${LIBRARY_NAME}_HEADERS}
57     ${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME}_EXPORT.h
58     )
59   
60
61 ENDMACRO(CREA_DYNAMIC_LIBRARY_EXPORT_OPTION LIBRARY_NAME)
62
63
64 # Manages the shared library creation/use 
65 # * Generates the file ${LIBRARY_NAME}_EXPORT.h which 
66 #   defines the symbols ${LIBRARY_NAME}_EXPORT and ${LIBRARY_NAME}_CDECL
67 #   to be used in exported classes/functions declarations
68 MACRO(CREA_DYNAMIC_LIBRARY_EXPORT LIBRARY_NAME)
69
70   CREA_DEFINE(${LIBRARY_NAME}_BUILD_SHARED)
71   CREA_DEFINE(${LIBRARY_NAME}_EXPORT_SYMBOLS)
72
73   # ADDS CURRENT BINARY DIR TO INCLUDE DIRS
74   INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
75
76   # CONFIGURES ${LIBRARY_NAME}_EXPORT.h
77   SET(LIBRARY_NAME ${LIBRARY_NAME})
78   CONFIGURE_FILE(
79     ${CREA_CMAKE_DIR}/LIBRARY_NAME_EXPORT.h.in
80     ${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME}_EXPORT.h
81     @ONLY IMMEDIATE
82     )
83   # ADDS IT TO THE LIST OF HEADERS
84   SET(${LIBRARY_NAME}_HEADERS
85     ${${LIBRARY_NAME}_HEADERS}
86     ${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME}_EXPORT.h
87     )
88
89 ENDMACRO(CREA_DYNAMIC_LIBRARY_EXPORT LIBRARY_NAME)