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 #----------------------------------------------------------------------------
13 #----------------------------------------------------------------------------
15 #----------------------------------------------------------------------------
16 # CREATES bb${BBTK_PACKAGE_NAME}Package.h
18 ${BBTK_CMAKE_DIR}/bbPackage.h.in
19 ${CMAKE_CURRENT_BINARY_DIR}/bb${BBTK_PACKAGE_NAME}Package.h
23 FILES ${CMAKE_CURRENT_BINARY_DIR}/bb${BBTK_PACKAGE_NAME}Package.h
24 DESTINATION include/bb${BBTK_PACKAGE_NAME}
26 #----------------------------------------------------------------------------
28 #----------------------------------------------------------------------------
29 # CREATES bb${BBTK_PACKAGE_NAME}Package.cxx
31 ${BBTK_CMAKE_DIR}/bbPackage.cxx.in
32 ${CMAKE_CURRENT_BINARY_DIR}/bb${BBTK_PACKAGE_NAME}Package.cxx
35 #----------------------------------------------------------------------------
37 #----------------------------------------------------------------------------
38 SET_SOURCE_FILES_PROPERTIES(
39 ${CMAKE_CURRENT_BINARY_DIR}/bb${BBTK_PACKAGE_NAME}Package.cxx
40 PROPERTIES GENERATED ON)
41 #----------------------------------------------------------------------------
44 #----------------------------------------------------------------------------
45 IF(${BBTK_PACKAGE_NAME}_COMPILE_ALL_CXX)
46 FILE(GLOB ${BBTK_PACKAGE_NAME}_CXX_SOURCES "." "*.cxx")
47 FILE(GLOB ${BBTK_PACKAGE_NAME}_H_SOURCES "." "*.h")
48 ENDIF(${BBTK_PACKAGE_NAME}_COMPILE_ALL_CXX)
51 SET(${BBTK_PACKAGE_NAME}_CXX_SOURCES
52 ${${BBTK_PACKAGE_NAME}_CXX_SOURCES}
53 #${CMAKE_CURRENT_BINARY_DIR_NAME}/
54 bb${BBTK_PACKAGE_NAME}Package
56 #----------------------------------------------------------------------------
59 #----------------------------------------------------------------------------
60 #----------------------------------------------------------------------------
62 #----------------------------------------------------------------------------
64 #----------------------------------------------------------------------------
65 IF(${BBTK_PACKAGE_NAME}_COMPILE_ALL_XML)
66 FILE(GLOB ${BBTK_PACKAGE_NAME}_XML_SOURCES "." "*.xml")
67 ENDIF(${BBTK_PACKAGE_NAME}_COMPILE_ALL_XML)
68 #----------------------------------------------------------------------------
69 FOREACH(xmlfile ${${BBTK_PACKAGE_NAME}_XML_SOURCES})
71 GET_FILENAME_COMPONENT(filename "${xmlfile}" NAME_WE)
73 SET(BBFY_CXX_OUT ${CMAKE_CURRENT_BINARY_DIR}/${filename}.cxx)
76 SET(command00 Path=%WXWIN%/lib/vc_dll/__RR__%VTK_DIR%__RR__%ITK_DIR%/../../bin/__RR__%PATH%)
77 STRING(REPLACE "__RR__" "\;" SETPATH ${command00} )
78 # SET(SETPATH set ${command0} &&)
80 OUTPUT ${BBFY_CXX_OUT}
82 set ${SETPATH} && ${BBTK_BBFY} ${xmlfile} ${BBTK_PACKAGE_NAME} ${CMAKE_CURRENT_BINARY_DIR}/ -q
84 ${BBTK_BBFY_DEPENDENCY}
88 OUTPUT ${BBFY_CXX_OUT}
90 ${BBTK_BBFY} ${xmlfile} ${BBTK_PACKAGE_NAME} ${CMAKE_CURRENT_BINARY_DIR}/ -q
92 ${BBTK_BBFY_DEPENDENCY}
98 SET_SOURCE_FILES_PROPERTIES(
100 PROPERTIES GENERATED ON)
103 IF(NOT ${BBTK_PACKAGE_NAME}_CXX_SOURCES MATCHES "${filename}.cxx")
104 # message ("EED Alert BBTKConfigurePackage_src " "IF NOT MATCHES" )
105 SET(${BBTK_PACKAGE_NAME}_CXX_SOURCES
106 ${${BBTK_PACKAGE_NAME}_CXX_SOURCES}
109 ENDIF(NOT ${BBTK_PACKAGE_NAME}_CXX_SOURCES MATCHES "${filename}.cxx")
112 FILES ${CMAKE_CURRENT_BINARY_DIR}/${filename}.h
113 DESTINATION include/bb${BBTK_PACKAGE_NAME})
115 #----------------------------------------------------------------------------
119 #----------------------------------------------------------------------------
121 ADD_LIBRARY(bb${BBTK_PACKAGE_NAME} SHARED
122 ${${BBTK_PACKAGE_NAME}_CXX_SOURCES} ${${BBTK_PACKAGE_NAME}_H_SOURCES}
124 TARGET_LINK_LIBRARIES(bb${BBTK_PACKAGE_NAME}
126 ${${BBTK_PACKAGE_NAME}_LIBS}
128 #----------------------------------------------------------------------------
131 #----------------------------------------------------------------------------
133 FILE(GLOB ${BBTK_PACKAGE_NAME}_HEADERS "*.h")
135 FILES ${${BBTK_PACKAGE_NAME}_HEADERS}
136 DESTINATION include/bb${BBTK_PACKAGE_NAME}
139 TARGETS bb${BBTK_PACKAGE_NAME}
143 SET( LIBRARY_NAME bb${BBTK_PACKAGE_NAME} )
144 # SET THE LIB VERSION
145 SET(${LIBRARY_NAME}_MAJOR_VERSION ${${BBTK_PACKAGE_NAME}_MAJOR_VERSION})
146 SET(${LIBRARY_NAME}_MINOR_VERSION ${${BBTK_PACKAGE_NAME}_MINOR_VERSION})
147 SET(${LIBRARY_NAME}_BUILD_VERSION ${${BBTK_PACKAGE_NAME}_BUILD_VERSION})
149 SET(${LIBRARY_NAME}_INSTALL_FOLDER bb${BBTK_PACKAGE_NAME})
150 SET(${LIBRARY_NAME}_LIBRARIES bb${BBTK_PACKAGE_NAME})
153 ${LIBRARY_NAME}_BUILD_TREE_RELATIVE_INCLUDE_PATHS
154 ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
158 SET(${LIBRARY_NAME}_BUILD_TREE_RELATIVE_LIBRARY_PATHS
159 ${EXECUTABLE_OUTPUT_REL_PATH})
161 SET(${LIBRARY_NAME}_BUILD_TREE_RELATIVE_LIBRARY_PATHS
162 ${EXECUTABLE_OUTPUT_REL_PATH}/Debug
163 ${EXECUTABLE_OUTPUT_REL_PATH}/Release)
165 SET(${LIBRARY_NAME}_INSTALL_TREE_RELATIVE_INCLUDE_PATHS
166 include/bb${BBTK_PACKAGE_NAME})
167 SET(${LIBRARY_NAME}_INSTALL_TREE_RELATIVE_LIBRARY_PATHS lib)
169 # REQUIRED BUILD FLAGS
170 #SET(${LIBRARY_NAME}_REQUIRED_C_FLAGS "")
171 #SET(${LIBRARY_NAME}_REQUIRED_CXX_FLAGS "")
172 #SET(${LIBRARY_NAME}_REQUIRED_LINK_FLAGS "")
174 # Additional config/use
175 # Prepare for configure
176 SET(BBTK_PACKAGE_USE_VTK ${${BBTK_PACKAGE_NAME}_USE_VTK})
177 SET(BBTK_PACKAGE_USE_ITK ${${BBTK_PACKAGE_NAME}_USE_ITK})
178 SET(BBTK_PACKAGE_USE_GDCM ${${BBTK_PACKAGE_NAME}_USE_GDCM})
179 SET(BBTK_PACKAGE_USE_GSMIS ${${BBTK_PACKAGE_NAME}_USE_GSMIS})
180 SET(BBTK_PACKAGE_USE_WXWIDGETS ${${BBTK_PACKAGE_NAME}_USE_WXWIDGETS})
181 SET(BBTK_PACKAGE_USE_PACKAGES ${${BBTK_PACKAGE_NAME}_USE_PACKAGES})
182 SET(BBTK_PACKAGE_INCLUDE_DIRS ${${BBTK_PACKAGE_NAME}_INCLUDE_DIRS})
183 SET(BBTK_PACKAGE_LIBS ${${BBTK_PACKAGE_NAME}_LIBS})
185 SET(${LIBRARY_NAME}_HAS_ADDITIONAL_CONFIG_FILE TRUE)
186 SET(${LIBRARY_NAME}_ADDITIONAL_CONFIG_FILE
187 ${${BBTK_PACKAGE_NAME}_SOURCE_DIR}/PackageConfig.cmake.in)
188 SET(${LIBRARY_NAME}_ADDITIONAL_USE_FILE
189 ${${BBTK_PACKAGE_NAME}_SOURCE_DIR}/UsePackage.cmake.in)
190 #-----------------------------------------------------------------------------
192 #-----------------------------------------------------------------------------
193 # Includes CMakeCreateFindPackage
194 INCLUDE(${CMakeCreateFindPackage_DIR}/CMakeCreateFindPackage.cmake)
195 CMAKE_CREATE_FIND_PACKAGE(${LIBRARY_NAME})
196 #-----------------------------------------------------------------------------
198 #----------------------------------------------------------------------------
203 #---------------------------------------------------------------------------
205 # On recent linux running SELinux :
206 # Have to change the context of the library created
207 # to be able to load it dynamically and avoid the error :
208 # "cannot restore segment prot after reloc: Permission denied"
210 # http://www.ittvis.com/services/techtip.asp?ttid=3092
212 FIND_PROGRAM(CHCON_EXECUTABLE
218 MARK_AS_ADVANCED(CHCON_EXECUTABLE)
221 # custom post_build command to change the context of the .so generated
223 TARGET bb${BBTK_PACKAGE_NAME}
225 COMMAND chcon -t texrel_shlib_t ${LIBRARY_OUTPUT_PATH}/libbb${BBTK_PACKAGE_NAME}.so
227 # custom post-install command to change the context of the .so installed
228 INSTALL(CODE "EXEC_PROGRAM(chcon ARGS -t texrel_shlib_t ${CMAKE_INSTALL_PREFIX}/lib/libbb${BBTK_PACKAGE_NAME}.so)")
229 ENDIF(CHCON_EXECUTABLE)
230 ENDIF(CHCON_LIBRARIES)
231 #----------------------------------------------------------------------------