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 # USER DEFINED ADDITIONAL INCLUDE DIRS
13 # NB : PATHS PROVIDED BY THE USER ARE RELATIVE TO THE PARENT DIR
14 INCLUDE_DIRECTORIES(../${${BBTK_PACKAGE_NAME}_INCLUDE_DIRS})
15 #----------------------------------------------------------------------------
18 #----------------------------------------------------------------------------
20 #----------------------------------------------------------------------------
21 # CREATES bb${BBTK_PACKAGE_NAME}Package.h
23 ${BBTK_CMAKE_DIR}/bbPackage.h.in
24 ${CMAKE_CURRENT_BINARY_DIR}/bb${BBTK_PACKAGE_NAME}Package.h
28 FILES ${CMAKE_CURRENT_BINARY_DIR}/bb${BBTK_PACKAGE_NAME}Package.h
29 DESTINATION include/bb${BBTK_PACKAGE_NAME}
31 #----------------------------------------------------------------------------
33 #----------------------------------------------------------------------------
34 # CREATES bb${BBTK_PACKAGE_NAME}Package.cxx
36 ${BBTK_CMAKE_DIR}/bbPackage.cxx.in
37 ${CMAKE_CURRENT_BINARY_DIR}/bb${BBTK_PACKAGE_NAME}Package.cxx
40 #----------------------------------------------------------------------------
42 #----------------------------------------------------------------------------
43 SET_SOURCE_FILES_PROPERTIES(
44 ${CMAKE_CURRENT_BINARY_DIR}/bb${BBTK_PACKAGE_NAME}Package.cxx
45 PROPERTIES GENERATED ON)
46 #----------------------------------------------------------------------------
49 #----------------------------------------------------------------------------
50 IF(${BBTK_PACKAGE_NAME}_COMPILE_ALL_CXX)
51 FILE(GLOB ${BBTK_PACKAGE_NAME}_CXX_SOURCES "." "*.cxx")
52 FILE(GLOB ${BBTK_PACKAGE_NAME}_H_SOURCES "." "*.h")
53 ENDIF(${BBTK_PACKAGE_NAME}_COMPILE_ALL_CXX)
56 SET(${BBTK_PACKAGE_NAME}_CXX_SOURCES
57 ${${BBTK_PACKAGE_NAME}_CXX_SOURCES}
58 #${CMAKE_CURRENT_BINARY_DIR_NAME}/
59 bb${BBTK_PACKAGE_NAME}Package
61 #----------------------------------------------------------------------------
64 #----------------------------------------------------------------------------
65 #----------------------------------------------------------------------------
67 #----------------------------------------------------------------------------
69 #----------------------------------------------------------------------------
70 IF(${BBTK_PACKAGE_NAME}_COMPILE_ALL_XML)
71 FILE(GLOB ${BBTK_PACKAGE_NAME}_XML_SOURCES "." "*.xml")
72 ENDIF(${BBTK_PACKAGE_NAME}_COMPILE_ALL_XML)
73 #----------------------------------------------------------------------------
74 FOREACH(xmlfile ${${BBTK_PACKAGE_NAME}_XML_SOURCES})
76 GET_FILENAME_COMPONENT(filename "${xmlfile}" NAME_WE)
78 SET(BBFY_CXX_OUT ${CMAKE_CURRENT_BINARY_DIR}/${filename}.cxx)
81 SET(command00 Path=%WXWIN%/lib/vc_dll/__RR__%VTK_DIR%__RR__%ITK_DIR%/../../bin/__RR__%PATH%)
82 STRING(REPLACE "__RR__" "\;" SETPATH ${command00} )
83 # SET(SETPATH set ${command0} &&)
85 OUTPUT ${BBFY_CXX_OUT}
87 set ${SETPATH} && ${BBTK_BBFY} ${xmlfile} ${BBTK_PACKAGE_NAME} ${CMAKE_CURRENT_BINARY_DIR}/ -q
89 ${BBTK_BBFY_DEPENDENCY}
93 OUTPUT ${BBFY_CXX_OUT}
95 ${BBTK_BBFY} ${xmlfile} ${BBTK_PACKAGE_NAME} ${CMAKE_CURRENT_BINARY_DIR}/ -q
97 ${BBTK_BBFY_DEPENDENCY}
103 SET_SOURCE_FILES_PROPERTIES(
105 PROPERTIES GENERATED ON)
108 IF(NOT ${BBTK_PACKAGE_NAME}_CXX_SOURCES MATCHES "${filename}.cxx")
109 # message ("EED Alert BBTKConfigurePackage_src " "IF NOT MATCHES" )
110 SET(${BBTK_PACKAGE_NAME}_CXX_SOURCES
111 ${${BBTK_PACKAGE_NAME}_CXX_SOURCES}
114 ENDIF(NOT ${BBTK_PACKAGE_NAME}_CXX_SOURCES MATCHES "${filename}.cxx")
117 FILES ${CMAKE_CURRENT_BINARY_DIR}/${filename}.h
118 DESTINATION include/bb${BBTK_PACKAGE_NAME})
120 #----------------------------------------------------------------------------
124 #----------------------------------------------------------------------------
126 ADD_LIBRARY(bb${BBTK_PACKAGE_NAME} SHARED
127 ${${BBTK_PACKAGE_NAME}_CXX_SOURCES} ${${BBTK_PACKAGE_NAME}_H_SOURCES}
129 TARGET_LINK_LIBRARIES(bb${BBTK_PACKAGE_NAME}
131 ${${BBTK_PACKAGE_NAME}_LIBS}
133 #----------------------------------------------------------------------------
136 #----------------------------------------------------------------------------
138 FILE(GLOB ${BBTK_PACKAGE_NAME}_HEADERS "*.h")
140 FILES ${${BBTK_PACKAGE_NAME}_HEADERS}
141 DESTINATION include/bb${BBTK_PACKAGE_NAME}
144 TARGETS bb${BBTK_PACKAGE_NAME}
148 SET( LIBRARY_NAME bb${BBTK_PACKAGE_NAME} )
149 # SET THE LIB VERSION
150 SET(${LIBRARY_NAME}_MAJOR_VERSION ${${BBTK_PACKAGE_NAME}_MAJOR_VERSION})
151 SET(${LIBRARY_NAME}_MINOR_VERSION ${${BBTK_PACKAGE_NAME}_MINOR_VERSION})
152 SET(${LIBRARY_NAME}_BUILD_VERSION ${${BBTK_PACKAGE_NAME}_BUILD_VERSION})
154 SET(${LIBRARY_NAME}_INSTALL_FOLDER bb${BBTK_PACKAGE_NAME})
155 SET(${LIBRARY_NAME}_LIBRARIES bb${BBTK_PACKAGE_NAME})
158 ${LIBRARY_NAME}_BUILD_TREE_RELATIVE_INCLUDE_PATHS
159 ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
163 SET(${LIBRARY_NAME}_BUILD_TREE_RELATIVE_LIBRARY_PATHS
164 ${EXECUTABLE_OUTPUT_REL_PATH})
166 SET(${LIBRARY_NAME}_BUILD_TREE_RELATIVE_LIBRARY_PATHS
167 ${EXECUTABLE_OUTPUT_REL_PATH}/Debug
168 ${EXECUTABLE_OUTPUT_REL_PATH}/Release)
170 SET(${LIBRARY_NAME}_INSTALL_TREE_RELATIVE_INCLUDE_PATHS
171 include/bb${BBTK_PACKAGE_NAME})
172 SET(${LIBRARY_NAME}_INSTALL_TREE_RELATIVE_LIBRARY_PATHS lib)
174 # REQUIRED BUILD FLAGS
175 #SET(${LIBRARY_NAME}_REQUIRED_C_FLAGS "")
176 #SET(${LIBRARY_NAME}_REQUIRED_CXX_FLAGS "")
177 #SET(${LIBRARY_NAME}_REQUIRED_LINK_FLAGS "")
179 # Additional config/use
180 # Prepare for configure
181 SET(BBTK_PACKAGE_USE_VTK ${${BBTK_PACKAGE_NAME}_USE_VTK})
182 SET(BBTK_PACKAGE_USE_ITK ${${BBTK_PACKAGE_NAME}_USE_ITK})
183 SET(BBTK_PACKAGE_USE_GDCM ${${BBTK_PACKAGE_NAME}_USE_GDCM})
184 SET(BBTK_PACKAGE_USE_GSMIS ${${BBTK_PACKAGE_NAME}_USE_GSMIS})
185 SET(BBTK_PACKAGE_USE_WXWIDGETS ${${BBTK_PACKAGE_NAME}_USE_WXWIDGETS})
186 SET(BBTK_PACKAGE_USE_PACKAGES ${${BBTK_PACKAGE_NAME}_USE_PACKAGES})
187 SET(BBTK_PACKAGE_INCLUDE_DIRS ${${BBTK_PACKAGE_NAME}_INCLUDE_DIRS})
188 SET(BBTK_PACKAGE_LIBS ${${BBTK_PACKAGE_NAME}_LIBS})
190 SET(${LIBRARY_NAME}_HAS_ADDITIONAL_CONFIG_FILE TRUE)
191 SET(${LIBRARY_NAME}_ADDITIONAL_CONFIG_FILE
192 ${${BBTK_PACKAGE_NAME}_SOURCE_DIR}/PackageConfig.cmake.in)
193 SET(${LIBRARY_NAME}_ADDITIONAL_USE_FILE
194 ${${BBTK_PACKAGE_NAME}_SOURCE_DIR}/UsePackage.cmake.in)
195 #-----------------------------------------------------------------------------
197 #-----------------------------------------------------------------------------
198 # Includes CMakeCreateFindPackage
199 INCLUDE(${CMakeCreateFindPackage_DIR}/CMakeCreateFindPackage.cmake)
200 CMAKE_CREATE_FIND_PACKAGE(${LIBRARY_NAME})
201 #-----------------------------------------------------------------------------
203 #----------------------------------------------------------------------------
208 #---------------------------------------------------------------------------
210 # On recent linux running SELinux :
211 # Have to change the context of the library created
212 # to be able to load it dynamically and avoid the error :
213 # "cannot restore segment prot after reloc: Permission denied"
215 # http://www.ittvis.com/services/techtip.asp?ttid=3092
217 FIND_PROGRAM(CHCON_EXECUTABLE
223 MARK_AS_ADVANCED(CHCON_EXECUTABLE)
226 # custom post_build command to change the context of the .so generated
228 TARGET bb${BBTK_PACKAGE_NAME}
230 COMMAND chcon -t texrel_shlib_t ${LIBRARY_OUTPUT_PATH}/libbb${BBTK_PACKAGE_NAME}.so
232 # custom post-install command to change the context of the .so installed
233 INSTALL(CODE "EXEC_PROGRAM(chcon ARGS -t texrel_shlib_t ${CMAKE_INSTALL_PREFIX}/lib/libbb${BBTK_PACKAGE_NAME}.so)")
234 ENDIF(CHCON_EXECUTABLE)
235 ENDIF(CHCON_LIBRARIES)
236 #----------------------------------------------------------------------------