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}Package.h
14 ${BBTK_DIR}/bbPackage.h.in
15 ${CMAKE_CURRENT_BINARY_DIR}/bb${BBTK_PACKAGE_NAME}Package.h
19 /include/bb${BBTK_PACKAGE_NAME}
21 bb${BBTK_PACKAGE_NAME}Package.h)
22 #----------------------------------------------------------------------------
24 #----------------------------------------------------------------------------
25 # CREATES bb${BBTK_PACKAGE_NAME}Package.cxx
27 ${BBTK_DIR}/bbPackage.cxx.in
28 ${CMAKE_CURRENT_BINARY_DIR}/bb${BBTK_PACKAGE_NAME}Package.cxx
31 #----------------------------------------------------------------------------
33 #----------------------------------------------------------------------------
34 SET_SOURCE_FILES_PROPERTIES(
35 ${CMAKE_CURRENT_BINARY_DIR}/bb${BBTK_PACKAGE_NAME}Package.cxx
36 PROPERTIES GENERATED ON)
37 #----------------------------------------------------------------------------
40 #----------------------------------------------------------------------------
41 IF(BBTK_PACKAGE_COMPILE_ALL_CXX)
42 FILE(GLOB BBTK_PACKAGE_CXX_SOURCES "." "*.cxx")
43 FILE(GLOB BBTK_PACKAGE_H_SOURCES "." "*.h")
44 ENDIF(BBTK_PACKAGE_COMPILE_ALL_CXX)
47 SET(BBTK_PACKAGE_CXX_SOURCES
48 ${BBTK_PACKAGE_CXX_SOURCES}
49 #${CMAKE_CURRENT_BINARY_DIR_NAME}/
50 bb${BBTK_PACKAGE_NAME}Package
52 #----------------------------------------------------------------------------
55 #----------------------------------------------------------------------------
56 #----------------------------------------------------------------------------
58 #----------------------------------------------------------------------------
60 #----------------------------------------------------------------------------
61 IF(BBTK_PACKAGE_COMPILE_ALL_XML)
62 FILE(GLOB BBTK_PACKAGE_XML_SOURCES "." "*.xml")
63 ENDIF(BBTK_PACKAGE_COMPILE_ALL_XML)
64 #----------------------------------------------------------------------------
65 FOREACH(xmlfile ${BBTK_PACKAGE_XML_SOURCES})
67 GET_FILENAME_COMPONENT(filename "${xmlfile}" NAME_WE)
70 # SET(BBFY_DEPENDENCY_STR ${bbfy_EXECUTABLE})
71 # ENDIF(BBFY_DEPENDENCY)
73 SET(BBFY_CXX_OUT ${CMAKE_CURRENT_BINARY_DIR}/${filename}.cxx)
76 OUTPUT ${BBFY_CXX_OUT}
78 ${BBTK_BBFY} ${xmlfile} ${CMAKE_CURRENT_BINARY_DIR}/ -q
80 # LG : REMOVE AUTOMATIC DEPEDENCY ON bbfy BECAUSE CAUSED ALWAYS REBUILD xml BOXES WHEN bbtk CHANGED HENCE bbfy CHANGED
81 ${BBFY_DEPENDENCY_STR}
85 SET_SOURCE_FILES_PROPERTIES(
87 PROPERTIES GENERATED ON)
90 IF(NOT BBTK_PACKAGE_CXX_SOURCES MATCHES "${filename}")
91 SET(BBTK_PACKAGE_CXX_SOURCES
92 ${BBTK_PACKAGE_CXX_SOURCES}
95 ENDIF(NOT BBTK_PACKAGE_CXX_SOURCES MATCHES "${filename}")
97 INSTALL_FILES(/include/bb${BBTK_PACKAGE_NAME} FILES ${filename}.h)
100 #----------------------------------------------------------------------------
104 #----------------------------------------------------------------------------
106 ADD_LIBRARY(bb${BBTK_PACKAGE_NAME} SHARED
107 ${BBTK_PACKAGE_CXX_SOURCES} ${BBTK_PACKAGE_H_SOURCES}
109 TARGET_LINK_LIBRARIES(bb${BBTK_PACKAGE_NAME}
113 #----------------------------------------------------------------------------
116 #----------------------------------------------------------------------------
118 # NOW USES THE InstallLibrary.cmake
119 SET( LIBRARY_NAME bb${BBTK_PACKAGE_NAME} )
120 # SET THE LIB VERSION
121 SET(${LIBRARY_NAME}_MAJOR_VERSION ${BBTK_PACKAGE_MAJOR_VERSION})
122 SET(${LIBRARY_NAME}_MINOR_VERSION ${BBTK_PACKAGE_MINOR_VERSION})
123 SET(${LIBRARY_NAME}_BUILD_VERSION ${BBTK_PACKAGE_BUILD_VERSION})
125 #SET(INSTALL_LIBRARY_PATH ../cmake)
126 # Include the file 'InstallLibrary.cmake' which does the clean install job
127 #INCLUDE(${INSTALL_LIBRARY_PATH}/InstallLibrary.cmake)
130 # DEPRECATED SYNTAX BUT WHICH WORKS !!
131 INSTALL_FILES(/include/bb${BBTK_PACKAGE_NAME} "\\.h$")
132 #INSTALL(FILES "$.h" DESTINATION include/${BBTK_PACKAGE_NAME})
133 INSTALL(TARGETS bb${BBTK_PACKAGE_NAME} DESTINATION lib)
134 # INSTALL_TARGETS(/lib bb${BBTK_PACKAGE_NAME})
135 #----------------------------------------------------------------------------
140 #---------------------------------------------------------------------------
142 # On recent linux running SELinux :
143 # Have to change the context of the library created
144 # to be able to load it dynamically and avoid the error :
145 # "cannot restore segment prot after reloc: Permission denied"
147 # http://www.ittvis.com/services/techtip.asp?ttid=3092
149 FIND_PROGRAM(CHCON_EXECUTABLE
155 MARK_AS_ADVANCED(CHCON_EXECUTABLE)
158 # custom post_build command to change the context of the .so generated
160 TARGET bb${BBTK_PACKAGE_NAME}
162 COMMAND chcon -t texrel_shlib_t ${LIBRARY_OUTPUT_PATH}/libbb${BBTK_PACKAGE_NAME}.so
164 # custom post-install command to change the context of the .so installed
165 INSTALL(CODE "EXEC_PROGRAM(chcon ARGS -t texrel_shlib_t ${CMAKE_INSTALL_PREFIX}/lib/libbb${BBTK_PACKAGE_NAME}.so)")
166 ENDIF(CHCON_EXECUTABLE)
167 ENDIF(CHCON_LIBRARIES)
168 #----------------------------------------------------------------------------