#---------------------------------------------------------------------------- # BINARY DIR MUST BE IN INCLUDE DIRS # TO FIND .h OF AUTOMATICALLY GENERATED FILES (e.g. FROM XML) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ) # SOURCES DIR MUST ALSO BE IN INCLUDE DIRS FOR FILES COMPILED IN BINARY DIR # WHICH NEED TO INCLUDE OTHER FILES OF THE PACKAGE INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ) #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- # USER DEFINED ADDITIONAL INCLUDE DIRS # NB : PATHS PROVIDED BY THE USER ARE RELATIVE TO THE PARENT DIR INCLUDE_DIRECTORIES(../${${BBTK_PACKAGE_NAME}_INCLUDE_DIRS}) #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- # CREATES bb${BBTK_PACKAGE_NAME}Package.h CONFIGURE_FILE( ${BBTK_CMAKE_DIR}/bbPackage.h.in ${CMAKE_CURRENT_BINARY_DIR}/bb${BBTK_PACKAGE_NAME}Package.h @ONLY IMMEDIATE ) INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/bb${BBTK_PACKAGE_NAME}Package.h DESTINATION include/bb${BBTK_PACKAGE_NAME} ) #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- # CREATES bb${BBTK_PACKAGE_NAME}Package.cxx CONFIGURE_FILE( ${BBTK_CMAKE_DIR}/bbPackage.cxx.in ${CMAKE_CURRENT_BINARY_DIR}/bb${BBTK_PACKAGE_NAME}Package.cxx @ONLY IMMEDIATE ) #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- SET_SOURCE_FILES_PROPERTIES( ${CMAKE_CURRENT_BINARY_DIR}/bb${BBTK_PACKAGE_NAME}Package.cxx PROPERTIES GENERATED ON) #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- IF(${BBTK_PACKAGE_NAME}_COMPILE_ALL_CXX) FILE(GLOB ${BBTK_PACKAGE_NAME}_CXX_SOURCES "." "*.cxx") FILE(GLOB ${BBTK_PACKAGE_NAME}_H_SOURCES "." "*.h") ENDIF(${BBTK_PACKAGE_NAME}_COMPILE_ALL_CXX) SET(${BBTK_PACKAGE_NAME}_CXX_SOURCES ${${BBTK_PACKAGE_NAME}_CXX_SOURCES} #${CMAKE_CURRENT_BINARY_DIR_NAME}/ bb${BBTK_PACKAGE_NAME}Package ) #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- # bbfy #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- IF(${BBTK_PACKAGE_NAME}_COMPILE_ALL_XML) FILE(GLOB ${BBTK_PACKAGE_NAME}_XML_SOURCES "." "*.xml") ENDIF(${BBTK_PACKAGE_NAME}_COMPILE_ALL_XML) #---------------------------------------------------------------------------- FOREACH(xmlfile ${${BBTK_PACKAGE_NAME}_XML_SOURCES}) GET_FILENAME_COMPONENT(filename "${xmlfile}" NAME_WE) SET(BBFY_CXX_OUT ${CMAKE_CURRENT_BINARY_DIR}/${filename}.cxx) IF (WIN32) SET(command00 Path=%WXWIN%/lib/vc_dll/__RR__%VTK_DIR%__RR__%ITK_DIR%/../../bin/__RR__%PATH% ) STRING(REPLACE "__RR__" "\;" command0 ${command00} ) SET(SETPATH "set ${command0} &&") ELSE(WIN32) SET(SETPATH "") ENDIF(WIN32) ADD_CUSTOM_COMMAND( OUTPUT ${BBFY_CXX_OUT} COMMAND ${SETPATH} ${BBTK_BBFY} ${xmlfile} ${BBTK_PACKAGE_NAME} ${CMAKE_CURRENT_BINARY_DIR}/ -q DEPENDS ${xmlfile} ${BBTK_BBFY_DEPENDENCY} ) SET_SOURCE_FILES_PROPERTIES( ${BBFY_CXX_OUT} PROPERTIES GENERATED ON) # IF(NOT ${BBTK_PACKAGE_NAME}_CXX_SOURCES MATCHES "${filename}") # message ("EED Alert BBTKConfigurePackage_src " "IF NOT MATCHES" ) SET(${BBTK_PACKAGE_NAME}_CXX_SOURCES ${${BBTK_PACKAGE_NAME}_CXX_SOURCES} ${filename} ) # ENDIF(NOT ${BBTK_PACKAGE_NAME}_CXX_SOURCES MATCHES "${filename}") INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/${filename}.h DESTINATION include/bb${BBTK_PACKAGE_NAME}) ENDFOREACH(xmlfile) #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- # CREATES LIBRARY ADD_LIBRARY(bb${BBTK_PACKAGE_NAME} SHARED ${${BBTK_PACKAGE_NAME}_CXX_SOURCES} ${${BBTK_PACKAGE_NAME}_H_SOURCES} ) TARGET_LINK_LIBRARIES(bb${BBTK_PACKAGE_NAME} bbtk ${${BBTK_PACKAGE_NAME}_LIBS} ) #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- # INSTALLS LIBRARY FILE(GLOB ${BBTK_PACKAGE_NAME}_HEADERS "*.h") INSTALL( FILES ${${BBTK_PACKAGE_NAME}_HEADERS} DESTINATION include/bb${BBTK_PACKAGE_NAME} ) INSTALL( TARGETS bb${BBTK_PACKAGE_NAME} DESTINATION lib) # CreateFindPackage SET( LIBRARY_NAME bb${BBTK_PACKAGE_NAME} ) # SET THE LIB VERSION SET(${LIBRARY_NAME}_MAJOR_VERSION ${${BBTK_PACKAGE_NAME}_MAJOR_VERSION}) SET(${LIBRARY_NAME}_MINOR_VERSION ${${BBTK_PACKAGE_NAME}_MINOR_VERSION}) SET(${LIBRARY_NAME}_BUILD_VERSION ${${BBTK_PACKAGE_NAME}_BUILD_VERSION}) # SET(${LIBRARY_NAME}_INSTALL_FOLDER bb${BBTK_PACKAGE_NAME}) SET(${LIBRARY_NAME}_LIBRARIES bb${BBTK_PACKAGE_NAME}) FILE(RELATIVE_PATH ${LIBRARY_NAME}_BUILD_TREE_RELATIVE_INCLUDE_PATHS ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ) IF(UNIX) SET(${LIBRARY_NAME}_BUILD_TREE_RELATIVE_LIBRARY_PATHS ${EXECUTABLE_OUTPUT_REL_PATH}) ELSE(UNIX) SET(${LIBRARY_NAME}_BUILD_TREE_RELATIVE_LIBRARY_PATHS ${EXECUTABLE_OUTPUT_REL_PATH}/Debug ${EXECUTABLE_OUTPUT_REL_PATH}/Release) ENDIF(UNIX) SET(${LIBRARY_NAME}_INSTALL_TREE_RELATIVE_INCLUDE_PATHS include/bb${BBTK_PACKAGE_NAME}) SET(${LIBRARY_NAME}_INSTALL_TREE_RELATIVE_LIBRARY_PATHS lib) # REQUIRED BUILD FLAGS #SET(${LIBRARY_NAME}_REQUIRED_C_FLAGS "") #SET(${LIBRARY_NAME}_REQUIRED_CXX_FLAGS "") #SET(${LIBRARY_NAME}_REQUIRED_LINK_FLAGS "") # Additional config/use # Prepare for configure SET(BBTK_PACKAGE_USE_VTK ${${BBTK_PACKAGE_NAME}_USE_VTK}) SET(BBTK_PACKAGE_USE_ITK ${${BBTK_PACKAGE_NAME}_USE_ITK}) SET(BBTK_PACKAGE_USE_GDCM ${${BBTK_PACKAGE_NAME}_USE_GDCM}) SET(BBTK_PACKAGE_USE_GSMIS ${${BBTK_PACKAGE_NAME}_USE_GSMIS}) SET(BBTK_PACKAGE_USE_WXWIDGETS ${${BBTK_PACKAGE_NAME}_USE_WXWIDGETS}) SET(BBTK_PACKAGE_USE_PACKAGES ${${BBTK_PACKAGE_NAME}_USE_PACKAGES}) SET(BBTK_PACKAGE_INCLUDE_DIRS ${${BBTK_PACKAGE_NAME}_INCLUDE_DIRS}) SET(BBTK_PACKAGE_LIBS ${${BBTK_PACKAGE_NAME}_LIBS}) SET(${LIBRARY_NAME}_HAS_ADDITIONAL_CONFIG_FILE TRUE) SET(${LIBRARY_NAME}_ADDITIONAL_CONFIG_FILE ${${BBTK_PACKAGE_NAME}_SOURCE_DIR}/PackageConfig.cmake.in) SET(${LIBRARY_NAME}_ADDITIONAL_USE_FILE ${${BBTK_PACKAGE_NAME}_SOURCE_DIR}/UsePackage.cmake.in) #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # Includes CMakeCreateFindPackage INCLUDE(${CMakeCreateFindPackage_DIR}/CMakeCreateFindPackage.cmake) CMAKE_CREATE_FIND_PACKAGE(${LIBRARY_NAME}) #----------------------------------------------------------------------------- #---------------------------------------------------------------------------- #--------------------------------------------------------------------------- IF(CHCON_LIBRARIES) # On recent linux running SELinux : # Have to change the context of the library created # to be able to load it dynamically and avoid the error : # "cannot restore segment prot after reloc: Permission denied" # see e.g. # http://www.ittvis.com/services/techtip.asp?ttid=3092 # Try to find chcon FIND_PROGRAM(CHCON_EXECUTABLE NAMES chcon PATHS /usr/bin /usr/local/bin ) MARK_AS_ADVANCED(CHCON_EXECUTABLE) IF(CHCON_EXECUTABLE) # chcon found # custom post_build command to change the context of the .so generated ADD_CUSTOM_COMMAND( TARGET bb${BBTK_PACKAGE_NAME} POST_BUILD COMMAND chcon -t texrel_shlib_t ${LIBRARY_OUTPUT_PATH}/libbb${BBTK_PACKAGE_NAME}.so ) # custom post-install command to change the context of the .so installed INSTALL(CODE "EXEC_PROGRAM(chcon ARGS -t texrel_shlib_t ${CMAKE_INSTALL_PREFIX}/lib/libbb${BBTK_PACKAGE_NAME}.so)") ENDIF(CHCON_EXECUTABLE) ENDIF(CHCON_LIBRARIES) #----------------------------------------------------------------------------