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}_EXPORT.h
13 CREA_DYNAMIC_LIBRARY_EXPORT(bb${BBTK_PACKAGE_NAME})
15 FILES ${CMAKE_CURRENT_BINARY_DIR}/bb${BBTK_PACKAGE_NAME}_EXPORT.h
16 DESTINATION include/bb${BBTK_PACKAGE_NAME}
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}_CPP_SOURCES "." "*.cpp")
53 SET(${BBTK_PACKAGE_NAME}_CXX_SOURCES ${${BBTK_PACKAGE_NAME}_CXX_SOURCES} ${${BBTK_PACKAGE_NAME}_CPP_SOURCES})
54 FILE(GLOB ${BBTK_PACKAGE_NAME}_H_SOURCES "." "*.h")
55 ENDIF(${BBTK_PACKAGE_NAME}_COMPILE_ALL_CXX)
57 IF(NOT PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
58 SET(${BBTK_PACKAGE_NAME}_CXX_SOURCES
59 ${${BBTK_PACKAGE_NAME}_CXX_SOURCES}
60 bb${BBTK_PACKAGE_NAME}Package
62 ENDIF(NOT PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
63 #----------------------------------------------------------------------------
66 #----------------------------------------------------------------------------
67 #----------------------------------------------------------------------------
69 #----------------------------------------------------------------------------
71 #----------------------------------------------------------------------------
72 IF(${BBTK_PACKAGE_NAME}_COMPILE_ALL_XML)
73 FILE(GLOB ${BBTK_PACKAGE_NAME}_XML_SOURCES "." "*.xml")
74 ENDIF(${BBTK_PACKAGE_NAME}_COMPILE_ALL_XML)
75 #----------------------------------------------------------------------------
76 FOREACH(xmlfile ${${BBTK_PACKAGE_NAME}_XML_SOURCES})
77 GET_FILENAME_COMPONENT(filename "${xmlfile}" NAME_WE)
79 SET(BBFY_CXX_OUT ${CMAKE_CURRENT_BINARY_DIR}/${filename}.cxx)
83 # SET(command00 Path=c:/creatis/dlls__RR__%WXWIN%/lib/vc_dll/__RR__%VTK_DIR%__RR__%ITK_DIR%/../../bin/__RR__%PATH%)
84 # STRING(REPLACE "__RR__" "\;" SETPATH ${command00} )
85 # SET(SETPATH set ${command0} &&)
87 OUTPUT ${BBFY_CXX_OUT}
89 set Path=${DLL_PATH} && ${BBTK_BBFY} ${xmlfile} ${BBTK_PACKAGE_NAME} ${CMAKE_CURRENT_BINARY_DIR}/ -q
91 ${BBTK_BBFY_DEPENDENCY}
94 SET(LD_LIBRARY_PATH "$ENV{LD_LIBRARY_PATH}:${LIBRARY_OUTPUT_PATH}")
96 OUTPUT ${BBFY_CXX_OUT}
98 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH} && ${BBTK_BBFY} ${xmlfile} ${BBTK_PACKAGE_NAME} ${CMAKE_CURRENT_BINARY_DIR}/ -q
100 ${BBTK_BBFY_DEPENDENCY}
106 SET_SOURCE_FILES_PROPERTIES(
108 PROPERTIES GENERATED ON)
111 IF(NOT ${BBTK_PACKAGE_NAME}_CXX_SOURCES MATCHES "${filename}.cxx")
112 # message ("EED Alert BBTKConfigurePackage_src " "IF NOT MATCHES" )
113 SET(${BBTK_PACKAGE_NAME}_CXX_SOURCES
114 ${${BBTK_PACKAGE_NAME}_CXX_SOURCES}
117 ENDIF(NOT ${BBTK_PACKAGE_NAME}_CXX_SOURCES MATCHES "${filename}.cxx")
120 FILES ${CMAKE_CURRENT_BINARY_DIR}/${filename}.h
121 DESTINATION include/bb${BBTK_PACKAGE_NAME})
123 #----------------------------------------------------------------------------
127 #----------------------------------------------------------------------------
129 #----------------------------------------------------------------------------
130 # TCL WRAPPING FOR KWWIDGETS
131 IF(BBTK_USE_KWWIDGETS)
132 #MESSAGE(STATUS "****TCL=${${BBTK_PACKAGE_NAME}_CXX_SOURCES_WRAP_TCL}")
133 IF(${BBTK_PACKAGE_NAME}_CXX_SOURCES_WRAP_TCL )
134 #MESSAGE(STATUS "****TCL OK")
135 include("${KWWidgets_CMAKE_DIR}/KWWidgetsWrappingMacros.cmake")
136 kwwidgets_wrap_tcl(bb${BBTK_PACKAGE_NAME} LIB_TCL_SRCS ${${BBTK_PACKAGE_NAME}_CXX_SOURCES_WRAP_TCL} "")
137 SET(${BBTK_PACKAGE_NAME}_CXX_SOURCES
138 ${${BBTK_PACKAGE_NAME}_CXX_SOURCES}
140 ENDIF(${BBTK_PACKAGE_NAME}_CXX_SOURCES_WRAP_TCL)
141 ENDIF(BBTK_USE_KWWIDGETS)
142 #----------------------------------------------------------------------------
143 #MESSAGE(STATUS ${${BBTK_PACKAGE_NAME}_CXX_SOURCES})
145 ADD_LIBRARY(bb${BBTK_PACKAGE_NAME} SHARED
146 ${${BBTK_PACKAGE_NAME}_CXX_SOURCES} ${${BBTK_PACKAGE_NAME}_H_SOURCES}
150 TARGET_LINK_LIBRARIES(bb${BBTK_PACKAGE_NAME}
152 ${${BBTK_PACKAGE_NAME}_LIBS}
155 SET_TARGET_PROPERTIES(bb${BBTK_PACKAGE_NAME} PROPERTIES COMPILE_FLAGS -Wall)
157 #----------------------------------------------------------------------------
160 #----------------------------------------------------------------------------
162 FILE(GLOB ${BBTK_PACKAGE_NAME}_HEADERS "*.h")
164 FILES ${${BBTK_PACKAGE_NAME}_HEADERS}
165 DESTINATION include/bb${BBTK_PACKAGE_NAME}
168 TARGETS bb${BBTK_PACKAGE_NAME}
169 DESTINATION ${BBTK_PACKAGE_LIB_PATH}
173 # Preparing macro invocation : CREA_ADVANCED_INSTALL_LIBRARY_FOR_CMAKE
174 SET( LIBRARY_NAME bb${BBTK_PACKAGE_NAME} )
175 # SET THE LIB VERSION
176 SET(${LIBRARY_NAME}_MAJOR_VERSION ${${BBTK_PACKAGE_NAME}_MAJOR_VERSION})
177 SET(${LIBRARY_NAME}_MINOR_VERSION ${${BBTK_PACKAGE_NAME}_MINOR_VERSION})
178 SET(${LIBRARY_NAME}_BUILD_VERSION ${${BBTK_PACKAGE_NAME}_BUILD_VERSION})
180 SET(${LIBRARY_NAME}_INSTALL_FOLDER bb${BBTK_PACKAGE_NAME})
181 SET(${LIBRARY_NAME}_LIBRARIES bb${BBTK_PACKAGE_NAME})
184 ${LIBRARY_NAME}_BUILD_TREE_RELATIVE_INCLUDE_PATHS
185 ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
188 IF ( ${PROJECT_BINARY_DIR} STREQUAL ${EXECUTABLE_OUTPUT_PATH} )
189 SET(CILFC_EXECUTABLE_OUTPUT_REL_PATH ".")
190 ELSE ( ${PROJECT_BINARY_DIR} STREQUAL ${EXECUTABLE_OUTPUT_PATH} )
192 CILFC_EXECUTABLE_OUTPUT_REL_PATH
193 ${PROJECT_BINARY_DIR} ${EXECUTABLE_OUTPUT_PATH})
194 ENDIF ( ${PROJECT_BINARY_DIR} STREQUAL ${EXECUTABLE_OUTPUT_PATH} )
197 SET(${LIBRARY_NAME}_BUILD_TREE_RELATIVE_LIBRARY_PATHS
198 ${CILFC_EXECUTABLE_OUTPUT_REL_PATH})
200 SET(${LIBRARY_NAME}_BUILD_TREE_RELATIVE_LIBRARY_PATHS
201 ${CILFC_EXECUTABLE_OUTPUT_REL_PATH})
204 SET(${LIBRARY_NAME}_INSTALL_TREE_RELATIVE_INCLUDE_PATHS
205 include/bb${BBTK_PACKAGE_NAME})
206 SET(${LIBRARY_NAME}_INSTALL_TREE_RELATIVE_LIBRARY_PATHS ${BBTK_PACKAGE_LIB_PATH})
208 # REQUIRED BUILD FLAGS
209 #SET(${LIBRARY_NAME}_REQUIRED_C_FLAGS "")
210 #SET(${LIBRARY_NAME}_REQUIRED_CXX_FLAGS "")
211 #SET(${LIBRARY_NAME}_REQUIRED_LINK_FLAGS "")
213 # Additional config/use
214 # Prepare for configure
215 SET(BBTK_PACKAGE_USE_VTK ${${BBTK_PACKAGE_NAME}_USE_VTK})
216 SET(BBTK_PACKAGE_USE_ITK ${${BBTK_PACKAGE_NAME}_USE_ITK})
217 SET(BBTK_PACKAGE_USE_QT ${${BBTK_PACKAGE_NAME}_USE_QT})
218 SET(BBTK_PACKAGE_USE_GDCM ${${BBTK_PACKAGE_NAME}_USE_GDCM})
219 SET(BBTK_PACKAGE_USE_GDCM2 ${${BBTK_PACKAGE_NAME}_USE_GDCM2})
220 SET(BBTK_PACKAGE_USE_GSMIS ${${BBTK_PACKAGE_NAME}_USE_GSMIS})
221 SET(BBTK_PACKAGE_USE_WXWIDGETS ${${BBTK_PACKAGE_NAME}_USE_WXWIDGETS})
222 SET(BBTK_PACKAGE_USE_PACKAGES ${${BBTK_PACKAGE_NAME}_USE_PACKAGES})
223 SET(BBTK_PACKAGE_INCLUDE_DIRS ${${BBTK_PACKAGE_NAME}_INCLUDE_DIRS})
224 SET(BBTK_PACKAGE_LIBS ${${BBTK_PACKAGE_NAME}_LIBS})
226 SET(${LIBRARY_NAME}_HAS_ADDITIONAL_CONFIG_FILE TRUE)
227 SET(${LIBRARY_NAME}_ADDITIONAL_CONFIG_FILE
228 ${${BBTK_PACKAGE_NAME}_SOURCE_DIR}/PackageConfig.cmake.in)
229 SET(${LIBRARY_NAME}_ADDITIONAL_USE_FILE
230 ${${BBTK_PACKAGE_NAME}_SOURCE_DIR}/UsePackage.cmake.in)
231 #-----------------------------------------------------------------------------
233 #-----------------------------------------------------------------------------
234 CREA_ADVANCED_INSTALL_LIBRARY_FOR_CMAKE(${LIBRARY_NAME})
235 #-----------------------------------------------------------------------------
237 #----------------------------------------------------------------------------
242 #---------------------------------------------------------------------------
244 # On recent linux running SELinux :
245 # Have to change the context of the library created
246 # to be able to load it dynamically and avoid the error :
247 # "cannot restore segment prot after reloc: Permission denied"
249 # http://www.ittvis.com/services/techtip.asp?ttid=3092
251 FIND_PROGRAM(CHCON_EXECUTABLE
257 MARK_AS_ADVANCED(CHCON_EXECUTABLE)
260 # custom post_build command to change the context of the .so generated
262 TARGET bb${BBTK_PACKAGE_NAME}
264 COMMAND chcon -t texrel_shlib_t ${LIBRARY_OUTPUT_PATH}/libbb${BBTK_PACKAGE_NAME}.so
266 # custom post-install command to change the context of the .so installed
267 INSTALL(CODE "EXEC_PROGRAM(chcon ARGS -t texrel_shlib_t ${CMAKE_INSTALL_PREFIX}/lib/libbb${BBTK_PACKAGE_NAME}.so)")
268 ENDIF(CHCON_EXECUTABLE)
269 ENDIF(CHCON_LIBRARIES)
270 #----------------------------------------------------------------------------