]> Creatis software - crea.git/blob - CREAMacro_DynamicLibraryExport.cmake
67f9277006637bea73bcf04dad7ddb02a98f0779
[crea.git] / CREAMacro_DynamicLibraryExport.cmake
1 # Manages the shared library creation/use 
2 # * Creates an option ${LIBRARY_NAME}_BUILD_SHARED 
3 # * Generates the file ${LIBRARY_NAME}_EXPORT.h which 
4 #   defines the symbols ${LIBRARY_NAME}_EXPORT and ${LIBRARY_NAME}_CDECL
5 #   to be used in exported classes/functions declarations
6 MACRO(CREA_DYNAMIC_LIBRARY_EXPORT_OPTION LIBRARY_NAME)
7
8   # STATIC OR DYNAMIC (SHARED) ? 
9   OPTION( ${LIBRARY_NAME}_BUILD_SHARED 
10     "Build ${LIBRARY_NAME} as a shared library (dynamic) ?" ON)
11   IF (${LIBRARY_NAME}_BUILD_SHARED)
12     SET(${LIBRARY_NAME}_SHARED SHARED)
13     CREA_DEFINE(${LIBRARY_NAME}_BUILD_SHARED)
14   ENDIF(${LIBRARY_NAME}_BUILD_SHARED)
15   
16   CREA_DEFINE(${LIBRARY_NAME}_EXPORT_SYMBOLS)
17
18   # ADDS CURRENT BINARY DIR TO INCLUDE DIRS
19   INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
20
21   # CONFIGURES ${LIBRARY_NAME}_EXPORT.h
22   CONFIGURE_FILE(
23     ${CREA_CMAKE_DIR}/LIBRARY_NAME_EXPORT.h.in
24     ${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME}_EXPORT.h
25     @ONLY IMMEDIATE
26     )
27   # ADDS IT TO THE LIST OF HEADERS
28   SET(${LIBRARY_NAME}_HEADERS
29     ${${LIBRARY_NAME}_HEADERS}
30     ${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME}_EXPORT.h
31     )
32   
33
34 ENDMACRO(CREA_DYNAMIC_LIBRARY_EXPORT_OPTION LIBRARY_NAME)
35
36
37 # Manages the shared library creation/use 
38 # * Generates the file ${LIBRARY_NAME}_EXPORT.h which 
39 #   defines the symbols ${LIBRARY_NAME}_EXPORT and ${LIBRARY_NAME}_CDECL
40 #   to be used in exported classes/functions declarations
41 MACRO(CREA_DYNAMIC_LIBRARY_EXPORT LIBRARY_NAME)
42
43   CREA_DEFINE(${LIBRARY_NAME}_BUILD_SHARED)
44   CREA_DEFINE(${LIBRARY_NAME}_EXPORT_SYMBOLS)
45
46   # ADDS CURRENT BINARY DIR TO INCLUDE DIRS
47   INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
48
49   # CONFIGURES ${LIBRARY_NAME}_EXPORT.h
50   SET(LIBRARY_NAME ${LIBRARY_NAME})
51   CONFIGURE_FILE(
52     ${CREA_CMAKE_DIR}/LIBRARY_NAME_EXPORT.h.in
53     ${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME}_EXPORT.h
54     @ONLY IMMEDIATE
55     )
56   # ADDS IT TO THE LIST OF HEADERS
57   SET(${LIBRARY_NAME}_HEADERS
58     ${${LIBRARY_NAME}_HEADERS}
59     ${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME}_EXPORT.h
60     )
61
62 ENDMACRO(CREA_DYNAMIC_LIBRARY_EXPORT LIBRARY_NAME)