]> Creatis software - crea.git/blob - cmake/CREAMacro_ManageSharedLibrary.cmake
0789f00329d7e3cfa5ebc58a805fcf498ef7342e
[crea.git] / cmake / CREAMacro_ManageSharedLibrary.cmake
1 # Manages the shared library creation/use 
2 # * Creates an option ${LIBRARY_NAME}_BUILD_SHARED 
3 # * Generates the file ${LIBRARY_NAME}DLLImportExport.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_MANAGE_SHARED_LIBRARY LIBRARY_NAME)
7
8   # STATIC OR DYNAMIC (SHARED) ? 
9   OPTION( ${LIBRARY_NAME}_BUILD_SHARED  
10   #JPR 8 Avr 2011 ON-> OFF, to avoid troubles with unaware users
11     "Build ${LIBRARY_NAME} as a shared library (dynamic) ?" OFF)
12   IF (${LIBRARY_NAME}_BUILD_SHARED)
13     SET(${LIBRARY_NAME}_SHARED SHARED)
14     CREA_DEFINE(${LIBRARY_NAME}_BUILD_SHARED)
15   ENDIF(${LIBRARY_NAME}_BUILD_SHARED)
16   
17   CREA_DEFINE(${LIBRARY_NAME}_EXPORT_SYMBOLS)
18
19   # ADDS CURRENT BINARY DIR TO INCLUDE DIRS
20   INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
21
22   # CONFIGURES ${LIBRARY_NAME}DLLImportExport.h
23   CONFIGURE_FILE(
24     ${CREA_CMAKE_DIR}/LIBRARY_NAMEDLLImportExport.h.in
25     ${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME}DLLImportExport.h
26     @ONLY IMMEDIATE
27     )
28   # ADDS IT TO THE LIST OF HEADERS
29   SET(${LIBRARY_NAME}_HEADERS
30     ${${LIBRARY_NAME}_HEADERS}
31     ${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME}DLLImportExport.h
32     )
33   
34
35 ENDMACRO(CREA_MANAGE_SHARED_LIBRARY LIBRARY_NAME)
36