2 #----------------------------------------------------------------------------
3 # BINARY DIR MUST BE IN INCLUDE DIRS
4 # TO FIND .h OF AUTOMATICALLY GENERATED FILES (e.g. FROM XML)
5 INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} )
6 # SOURCES DIR MUST ALSO BE IN INCLUDE DIRS FOR FILES COMPILED IN BINARY DIR
7 # WHICH NEED TO INCLUDE OTHER FILES OF THE PACKAGE
8 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} )
9 #----------------------------------------------------------------------------
11 #----------------------------------------------------------------------------
12 # CREATES bb${BBTK_PACKAGE_NAME}Package.h
14 ${BBTK_CMAKE_DIR}/bbPackage.h.in
15 ${CMAKE_CURRENT_BINARY_DIR}/bb${BBTK_PACKAGE_NAME}Package.h
19 FILES ${CMAKE_CURRENT_BINARY_DIR}/bb${BBTK_PACKAGE_NAME}Package.h
20 DESTINATION include/bb${BBTK_PACKAGE_NAME}
22 #----------------------------------------------------------------------------
24 #----------------------------------------------------------------------------
25 # CREATES bb${BBTK_PACKAGE_NAME}Package.cxx
27 ${BBTK_CMAKE_DIR}/bbPackage.cxx.in
28 ${CMAKE_CURRENT_BINARY_DIR}/bb${BBTK_PACKAGE_NAME}Package.cxx
31 #----------------------------------------------------------------------------
33 #----------------------------------------------------------------------------
34 SET_SOURCE_FILES_PROPERTIES(
35 ${CMAKE_CURRENT_BINARY_DIR}/bb${BBTK_PACKAGE_NAME}Package.cxx
36 PROPERTIES GENERATED ON)
37 #----------------------------------------------------------------------------
40 #----------------------------------------------------------------------------
41 IF(BBTK_PACKAGE_COMPILE_ALL_CXX)
42 FILE(GLOB BBTK_PACKAGE_CXX_SOURCES "." "*.cxx")
43 FILE(GLOB BBTK_PACKAGE_H_SOURCES "." "*.h")
44 ENDIF(BBTK_PACKAGE_COMPILE_ALL_CXX)
47 SET(BBTK_PACKAGE_CXX_SOURCES
48 ${BBTK_PACKAGE_CXX_SOURCES}
49 #${CMAKE_CURRENT_BINARY_DIR_NAME}/
50 bb${BBTK_PACKAGE_NAME}Package
52 #----------------------------------------------------------------------------
55 #----------------------------------------------------------------------------
56 #----------------------------------------------------------------------------
58 #----------------------------------------------------------------------------
60 #----------------------------------------------------------------------------
61 IF(BBTK_PACKAGE_COMPILE_ALL_XML)
62 FILE(GLOB BBTK_PACKAGE_XML_SOURCES "." "*.xml")
63 ENDIF(BBTK_PACKAGE_COMPILE_ALL_XML)
64 #----------------------------------------------------------------------------
65 FOREACH(xmlfile ${BBTK_PACKAGE_XML_SOURCES})
67 GET_FILENAME_COMPONENT(filename "${xmlfile}" NAME_WE)
70 SET(BBFY_CXX_OUT ${CMAKE_CURRENT_BINARY_DIR}/${filename}.cxx)
73 OUTPUT ${BBFY_CXX_OUT}
75 ${BBTK_BBFY} ${xmlfile} ${CMAKE_CURRENT_BINARY_DIR}/ -q
77 ${BBTK_BBFY_DEPENDENCY}
80 SET_SOURCE_FILES_PROPERTIES(
82 PROPERTIES GENERATED ON)
85 IF(NOT BBTK_PACKAGE_CXX_SOURCES MATCHES "${filename}")
86 SET(BBTK_PACKAGE_CXX_SOURCES
87 ${BBTK_PACKAGE_CXX_SOURCES}
90 ENDIF(NOT BBTK_PACKAGE_CXX_SOURCES MATCHES "${filename}")
93 FILES ${CMAKE_CURRENT_BINARY_DIR}/${filename}.h
94 DESTINATION include/bb${BBTK_PACKAGE_NAME})
97 #----------------------------------------------------------------------------
101 #----------------------------------------------------------------------------
103 ADD_LIBRARY(bb${BBTK_PACKAGE_NAME} SHARED
104 ${BBTK_PACKAGE_CXX_SOURCES} ${BBTK_PACKAGE_H_SOURCES}
106 TARGET_LINK_LIBRARIES(bb${BBTK_PACKAGE_NAME}
110 #----------------------------------------------------------------------------
113 #----------------------------------------------------------------------------
115 FILE(GLOB ${BBTK_PACKAGE_NAME}_HEADERS "*.h")
117 FILES ${${BBTK_PACKAGE_NAME}_HEADERS}
118 DESTINATION include/bb${BBTK_PACKAGE_NAME}
121 TARGETS bb${BBTK_PACKAGE_NAME}
125 SET( LIBRARY_NAME bb${BBTK_PACKAGE_NAME} )
126 # SET THE LIB VERSION
127 SET(${LIBRARY_NAME}_MAJOR_VERSION ${BBTK_PACKAGE_MAJOR_VERSION})
128 SET(${LIBRARY_NAME}_MINOR_VERSION ${BBTK_PACKAGE_MINOR_VERSION})
129 SET(${LIBRARY_NAME}_BUILD_VERSION ${BBTK_PACKAGE_BUILD_VERSION})
131 SET(${LIBRARY_NAME}_INSTALL_FOLDER bb${BBTK_PACKAGE_NAME})
132 SET(${LIBRARY_NAME}_LIBRARIES bb${BBTK_PACKAGE_NAME})
135 ${LIBRARY_NAME}_BUILD_TREE_RELATIVE_INCLUDE_PATHS
136 ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
140 SET(${LIBRARY_NAME}_BUILD_TREE_RELATIVE_LIBRARY_PATHS
141 ${EXECUTABLE_OUTPUT_REL_PATH})
143 SET(${LIBRARY_NAME}_BUILD_TREE_RELATIVE_LIBRARY_PATHS
144 ${EXECUTABLE_OUTPUT_REL_PATH}/Debug
145 ${EXECUTABLE_OUTPUT_REL_PATH}/Release)
147 SET(${LIBRARY_NAME}_INSTALL_TREE_RELATIVE_INCLUDE_PATHS
148 include/bb${BBTK_PACKAGE_NAME})
149 SET(${LIBRARY_NAME}_INSTALL_TREE_RELATIVE_LIBRARY_PATHS lib)
152 # - Set the version of your library
153 # SET YOUR LIB VERSION
154 #SET(${LIBRARY_NAME}_MAJOR_VERSION 1)
155 #SET(${LIBRARY_NAME}_MINOR_VERSION 0)
156 #SET(${LIBRARY_NAME}_BUILD_VERSION 0)
157 # REQUIRED BUILD FLAGS
158 #SET(${LIBRARY_NAME}_REQUIRED_C_FLAGS "")
159 #SET(${LIBRARY_NAME}_REQUIRED_CXX_FLAGS "")
160 #SET(${LIBRARY_NAME}_REQUIRED_LINK_FLAGS "")
161 # ADDITIONAL CONFIG FILE
162 # HERE WE USE ONE TO EXPORT testLib_EXPORTED_VALUE
164 SET(${LIBRARY_NAME}_HAS_ADDITIONAL_CONFIG_FILE TRUE)
165 SET(${LIBRARY_NAME}_ADDITIONAL_CONFIG_FILE
166 ${PROJECT_SOURCE_DIR}/PackageConfig.cmake.in)
167 SET(${LIBRARY_NAME}_ADDITIONAL_USE_FILE
168 ${PROJECT_SOURCE_DIR}/UsePackage.cmake.in)
169 #-----------------------------------------------------------------------------
171 #-----------------------------------------------------------------------------
172 # Includes CMakeCreateFindPackage
173 INCLUDE(${CMakeCreateFindPackage_DIR}/CMakeCreateFindPackage.cmake)
174 CMAKE_CREATE_FIND_PACKAGE(${LIBRARY_NAME})
175 #-----------------------------------------------------------------------------
177 #----------------------------------------------------------------------------
182 #---------------------------------------------------------------------------
184 # On recent linux running SELinux :
185 # Have to change the context of the library created
186 # to be able to load it dynamically and avoid the error :
187 # "cannot restore segment prot after reloc: Permission denied"
189 # http://www.ittvis.com/services/techtip.asp?ttid=3092
191 FIND_PROGRAM(CHCON_EXECUTABLE
197 MARK_AS_ADVANCED(CHCON_EXECUTABLE)
200 # custom post_build command to change the context of the .so generated
202 TARGET bb${BBTK_PACKAGE_NAME}
204 COMMAND chcon -t texrel_shlib_t ${LIBRARY_OUTPUT_PATH}/libbb${BBTK_PACKAGE_NAME}.so
206 # custom post-install command to change the context of the .so installed
207 INSTALL(CODE "EXEC_PROGRAM(chcon ARGS -t texrel_shlib_t ${CMAKE_INSTALL_PREFIX}/lib/libbb${BBTK_PACKAGE_NAME}.so)")
208 ENDIF(CHCON_EXECUTABLE)
209 ENDIF(CHCON_LIBRARIES)
210 #----------------------------------------------------------------------------