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
18 INSTALL_FILES(/include/bb${BBTK_PACKAGE_NAME} FILES bb${BBTK_PACKAGE_NAME}Package.h)
19 #----------------------------------------------------------------------------
21 #----------------------------------------------------------------------------
22 # CREATES bb${BBTK_PACKAGE_NAME}Package.cxx
24 ${BBTK_DIR}/bbPackage.cxx.in
25 ${CMAKE_CURRENT_BINARY_DIR}/bb${BBTK_PACKAGE_NAME}Package.cxx
28 #----------------------------------------------------------------------------
30 #----------------------------------------------------------------------------
31 SET_SOURCE_FILES_PROPERTIES(
32 ${CMAKE_CURRENT_BINARY_DIR}/bb${BBTK_PACKAGE_NAME}Package.cxx
33 PROPERTIES GENERATED ON)
34 #----------------------------------------------------------------------------
37 #----------------------------------------------------------------------------
38 IF(BBTK_PACKAGE_COMPILE_ALL_CXX)
39 FILE(GLOB BBTK_PACKAGE_CXX_SOURCES "." "*.cxx")
40 FILE(GLOB BBTK_PACKAGE_H_SOURCES "." "*.h")
41 ENDIF(BBTK_PACKAGE_COMPILE_ALL_CXX)
44 SET(BBTK_PACKAGE_CXX_SOURCES
45 ${BBTK_PACKAGE_CXX_SOURCES}
46 #${CMAKE_CURRENT_BINARY_DIR_NAME}/
47 bb${BBTK_PACKAGE_NAME}Package
49 #----------------------------------------------------------------------------
52 #----------------------------------------------------------------------------
53 #----------------------------------------------------------------------------
55 #----------------------------------------------------------------------------
57 #----------------------------------------------------------------------------
58 IF(BBTK_PACKAGE_COMPILE_ALL_XML)
59 FILE(GLOB BBTK_PACKAGE_XML_SOURCES "." "*.xml")
60 ENDIF(BBTK_PACKAGE_COMPILE_ALL_XML)
61 #----------------------------------------------------------------------------
62 FOREACH(xmlfile ${BBTK_PACKAGE_XML_SOURCES})
64 GET_FILENAME_COMPONENT(filename "${xmlfile}" NAME_WE)
67 SET(bbfy_EXECUTABLE $(TargetDir)/bbfy.exe)
69 SET(bbfy_EXECUTABLE ${EXECUTABLE_OUTPUT_PATH}/bbfy)
73 SET(BBFY_DEPENDENCY_STR ${bbfy_EXECUTABLE})
74 ENDIF(BBFY_DEPENDENCY)
76 SET(BBFY_CXX_OUT ${CMAKE_CURRENT_BINARY_DIR}/${filename}.cxx)
79 OUTPUT ${BBFY_CXX_OUT}
81 ${bbfy_EXECUTABLE} ${xmlfile} ${CMAKE_CURRENT_BINARY_DIR}/ -q
83 # LG : REMOVE AUTOMATIC DEPEDENCY ON bbfy BECAUSE CAUSED ALWAYS REBUILD xml BOXES WHEN bbtk CHANGED HENCE bbfy CHANGED
84 ${BBFY_DEPENDENCY_STR}
88 SET_SOURCE_FILES_PROPERTIES(
90 PROPERTIES GENERATED ON)
93 IF(NOT BBTK_PACKAGE_CXX_SOURCES MATCHES "${filename}")
94 SET(BBTK_PACKAGE_CXX_SOURCES
95 ${BBTK_PACKAGE_CXX_SOURCES}
98 ENDIF(NOT BBTK_PACKAGE_CXX_SOURCES MATCHES "${filename}")
100 INSTALL_FILES(/include/bb${BBTK_PACKAGE_NAME} FILES ${filename}.h)
102 #----------------------------------------------------------------------------
106 #----------------------------------------------------------------------------
108 ADD_LIBRARY(bb${BBTK_PACKAGE_NAME} SHARED
109 ${BBTK_PACKAGE_CXX_SOURCES} ${BBTK_PACKAGE_H_SOURCES}
111 TARGET_LINK_LIBRARIES(bb${BBTK_PACKAGE_NAME}
113 # ${BBP_LINK_LIBRARIES}
116 #----------------------------------------------------------------------------
119 #----------------------------------------------------------------------------
121 # NOW USES THE InstallLibrary.cmake
122 SET( LIBRARY_NAME bb${BBTK_PACKAGE_NAME} )
123 # SET THE LIB VERSION
124 SET(${LIBRARY_NAME}_MAJOR_VERSION ${BBTK_PACKAGE_MAJOR_VERSION})
125 SET(${LIBRARY_NAME}_MINOR_VERSION ${BBTK_PACKAGE_MINOR_VERSION})
126 SET(${LIBRARY_NAME}_BUILD_VERSION ${BBTK_PACKAGE_BUILD_VERSION})
128 #SET(INSTALL_LIBRARY_PATH ../cmake)
129 # Include the file 'InstallLibrary.cmake' which does the clean install job
130 #INCLUDE(${INSTALL_LIBRARY_PATH}/InstallLibrary.cmake)
133 # DEPRECATED SYNTAX BUT WHICH WORKS !!
134 INSTALL_FILES(/include/bb${BBTK_PACKAGE_NAME} "\\.h$")
135 #INSTALL(FILES "$.h" DESTINATION include/${BBTK_PACKAGE_NAME})
136 INSTALL(TARGETS bb${BBTK_PACKAGE_NAME} DESTINATION lib)
137 # INSTALL_TARGETS(/lib bb${BBTK_PACKAGE_NAME})
138 #----------------------------------------------------------------------------
143 #---------------------------------------------------------------------------
145 # On recent linux running SELinux :
146 # Have to change the context of the library created
147 # to be able to load it dynamically and avoid the error :
148 # "cannot restore segment prot after reloc: Permission denied"
150 # http://www.ittvis.com/services/techtip.asp?ttid=3092
152 FIND_PROGRAM(CHCON_EXECUTABLE
158 MARK_AS_ADVANCED(CHCON_EXECUTABLE)
161 # custom post_build command to change the context of the .so generated
163 TARGET bb${BBTK_PACKAGE_NAME}
165 COMMAND chcon -t texrel_shlib_t ${LIBRARY_OUTPUT_PATH}/libbb${BBTK_PACKAGE_NAME}.so
167 # custom post-install command to change the context of the .so installed
168 INSTALL(CODE "EXEC_PROGRAM(chcon ARGS -t texrel_shlib_t ${CMAKE_INSTALL_PREFIX}/lib/libbb${BBTK_PACKAGE_NAME}.so)")
169 ENDIF(CHCON_EXECUTABLE)
170 ENDIF(CHCON_LIBRARIES)
171 #----------------------------------------------------------------------------