#---------------------------------------------------------------------------- # 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} ) #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- # 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_COMPILE_ALL_CXX) FILE(GLOB BBTK_PACKAGE_CXX_SOURCES "." "*.cxx") FILE(GLOB BBTK_PACKAGE_H_SOURCES "." "*.h") ENDIF(BBTK_PACKAGE_COMPILE_ALL_CXX) SET(BBTK_PACKAGE_CXX_SOURCES ${BBTK_PACKAGE_CXX_SOURCES} #${CMAKE_CURRENT_BINARY_DIR_NAME}/ bb${BBTK_PACKAGE_NAME}Package ) #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- # bbfy #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- IF(BBTK_PACKAGE_COMPILE_ALL_XML) FILE(GLOB BBTK_PACKAGE_XML_SOURCES "." "*.xml") ENDIF(BBTK_PACKAGE_COMPILE_ALL_XML) #---------------------------------------------------------------------------- FOREACH(xmlfile ${BBTK_PACKAGE_XML_SOURCES}) GET_FILENAME_COMPONENT(filename "${xmlfile}" NAME_WE) SET(BBFY_CXX_OUT ${CMAKE_CURRENT_BINARY_DIR}/${filename}.cxx) ADD_CUSTOM_COMMAND( OUTPUT ${BBFY_CXX_OUT} COMMAND ${BBTK_BBFY} ${xmlfile} ${CMAKE_CURRENT_BINARY_DIR}/ -q DEPENDS ${xmlfile} ${BBTK_BBFY_DEPENDENCY} ) SET_SOURCE_FILES_PROPERTIES( ${BBFY_CXX_OUT} PROPERTIES GENERATED ON) IF(NOT BBTK_PACKAGE_CXX_SOURCES MATCHES "${filename}") SET(BBTK_PACKAGE_CXX_SOURCES ${BBTK_PACKAGE_CXX_SOURCES} ${filename} ) ENDIF(NOT BBTK_PACKAGE_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_CXX_SOURCES} ${BBTK_PACKAGE_H_SOURCES} ) TARGET_LINK_LIBRARIES(bb${BBTK_PACKAGE_NAME} bbtk ${BBTK_PACKAGE_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_MAJOR_VERSION}) SET(${LIBRARY_NAME}_MINOR_VERSION ${BBTK_PACKAGE_MINOR_VERSION}) SET(${LIBRARY_NAME}_BUILD_VERSION ${BBTK_PACKAGE_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) # OPTIONAL # - Set the version of your library # SET YOUR LIB VERSION #SET(${LIBRARY_NAME}_MAJOR_VERSION 1) #SET(${LIBRARY_NAME}_MINOR_VERSION 0) #SET(${LIBRARY_NAME}_BUILD_VERSION 0) # REQUIRED BUILD FLAGS #SET(${LIBRARY_NAME}_REQUIRED_C_FLAGS "") #SET(${LIBRARY_NAME}_REQUIRED_CXX_FLAGS "") #SET(${LIBRARY_NAME}_REQUIRED_LINK_FLAGS "") # ADDITIONAL CONFIG FILE # HERE WE USE ONE TO EXPORT testLib_EXPORTED_VALUE # SET(${LIBRARY_NAME}_HAS_ADDITIONAL_CONFIG_FILE TRUE) SET(${LIBRARY_NAME}_ADDITIONAL_CONFIG_FILE ${PROJECT_SOURCE_DIR}/PackageConfig.cmake.in) SET(${LIBRARY_NAME}_ADDITIONAL_USE_FILE ${PROJECT_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) #----------------------------------------------------------------------------