fixed: compile issue
[opensg.git] / CMake / CMakeLists.packaging.unix.txt
blobd1e054565f2248c66919e0ac0426b78ea1000cb3
2 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
4 PROJECT(OpenSGPack)
6 IF("${${PROJECT_NAME}_SOURCE_DIR}"  STREQUAL "${${PROJECT_NAME}_BINARY_DIR}")
7   MESSAGE(FATAL_ERROR "OpenSG requires an out of source Build. \n"
8                       "Please create a separate binary directory and run "
9                       "CMake there.")
10 ENDIF("${${PROJECT_NAME}_SOURCE_DIR}"  STREQUAL "${${PROJECT_NAME}_BINARY_DIR}")
12 IF(CMAKE_INSTALL_PREFIX STREQUAL /usr/local)
13   SET(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/Pack.install 
14                            CACHE PATH "" FORCE)
15 ENDIF()
17 ################
18 # Ref Dir
19 ################
21 STRING(REGEX REPLACE /[^/]*/[^/]*/[^/]*$ "" _BASE_INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR})
23 #MESSAGE("BASE DIR : ${_BASE_INSTALL_DIR}")
25 ################
26 # includes 
27 ################
29 FILE(GLOB_RECURSE _${PROJECT_NAME}_INCLUDES 
30                   RELATIVE ${_BASE_INSTALL_DIR}
31                   ${_BASE_INSTALL_DIR}/include/*)
33 #MESSAGE("INC : ${_${PROJECT_NAME}_INCLUDES}")
35 FOREACH(_INCLUDE_ELEM ${_${PROJECT_NAME}_INCLUDES})
37   STRING(REGEX REPLACE /[^/]*$ "" _INST_PATH ${_INCLUDE_ELEM})
39   INSTALL(FILES ${_BASE_INSTALL_DIR}/${_INCLUDE_ELEM}
40                 DESTINATION ${_INST_PATH}
41                 PERMISSIONS OWNER_WRITE OWNER_READ
42                             GROUP_READ
43                             WORLD_READ
44                 COMPONENT headers)
46 ENDFOREACH()
48 ################
49 # libs 
50 ################
52 FILE(GLOB_RECURSE _${PROJECT_NAME}_LIBS
53                   RELATIVE ${_BASE_INSTALL_DIR}
54                   ${_BASE_INSTALL_DIR}/lib@OSG_LIBDIR_BASE_SUFFIX@/*)
57 FOREACH(_LIB_ELEM ${_${PROJECT_NAME}_LIBS})
59   STRING(REGEX REPLACE /[^/]*$ "" _INST_PATH ${_LIB_ELEM})
61   SET(_ELEM_COMPONENT libraries)
63   IF(${_INST_PATH} MATCHES /python[1-9]\\.[0-9]/)
64     IF(${_INST_PATH} MATCHES /debug/)
65       SET(_ELEM_COMPONENT python_debug)
66     ELSE()
67       SET(_ELEM_COMPONENT python)
68     ENDIF()
69   ELSEIF(${_INST_PATH} MATCHES /debug$)
70     SET(_ELEM_COMPONENT libraries_debug)
71   ENDIF()
73 #  MESSAGE("LIB : ${_LIB_ELEM} ${_ELEM_COMPONENT} ${_INST_PATH}")
75   INSTALL(FILES ${_BASE_INSTALL_DIR}/${_LIB_ELEM}
76                 DESTINATION ${_INST_PATH}
77                 PERMISSIONS OWNER_WRITE OWNER_READ
78                             GROUP_READ
79                             WORLD_READ
80                 COMPONENT ${_ELEM_COMPONENT})
82 ENDFOREACH()
85 ################
86 # bin
87 ################
89 FILE(GLOB_RECURSE _${PROJECT_NAME}_BIN
90                   RELATIVE ${_BASE_INSTALL_DIR}
91                   ${_BASE_INSTALL_DIR}/bin/*)
94 FOREACH(_BIN_ELEM ${_${PROJECT_NAME}_BIN})
96   STRING(REGEX REPLACE /[^/]*$ "" _INST_PATH ${_BIN_ELEM})
98   SET(_ELEM_COMPONENT development_tools)
100   IF(${_BIN_ELEM} MATCHES bin/app.*$)
101     SET(_ELEM_COMPONENT apps)
102   ELSEIF(${_BIN_ELEM} MATCHES bin/debug/app.*$)
103     SET(_ELEM_COMPONENT apps_debug)
104   ENDIF()
106 #  MESSAGE("BIN : ${_BIN_ELEM} ${_ELEM_COMPONENT} ${_INST_PATH}")
108   INSTALL(FILES ${_BASE_INSTALL_DIR}/${_BIN_ELEM}
109                 DESTINATION ${_INST_PATH}
110                 PERMISSIONS OWNER_WRITE OWNER_READ
111                             GROUP_READ
112                             WORLD_READ
113                 COMPONENT ${_ELEM_COMPONENT})
115 ENDFOREACH()
118 ################
119 # share 
120 ################
122 FILE(GLOB_RECURSE _${PROJECT_NAME}_SHARE
123                   RELATIVE ${_BASE_INSTALL_DIR}
124                   ${_BASE_INSTALL_DIR}/share/*)
126 #MESSAGE("SHARE IN : ${_${PROJECT_NAME}_SHARE}")
128 FOREACH(_SHARE_ELEM ${_${PROJECT_NAME}_SHARE})
130   STRING(REGEX REPLACE /[^/]*$ "" _INST_PATH ${_SHARE_ELEM})
132   SET(_ELEM_COMPONENT Unknown)
134   IF(NOT ${_INST_PATH} MATCHES /Packaging)
136     IF(${_INST_PATH} MATCHES /cmake)
137       SET(_ELEM_COMPONENT development_config)
138     ENDIF()
140     IF(${_INST_PATH} MATCHES /share/doc)
141       SET(_ELEM_COMPONENT libraries)
142     ENDIF()
144     IF(${_INST_PATH} MATCHES /Doc)
145       SET(_ELEM_COMPONENT doc)
146     ENDIF()
148     IF(${_INST_PATH} MATCHES /Doc$)
149       SET(BASE_DOC_DIR ${_INST_PATH})
150     ENDIF()
152     IF(${_INST_PATH} MATCHES /Examples/)
153       IF(${_INST_PATH} MATCHES /bin$)
154         SET(_ELEM_COMPONENT examples_rel)
155       ELSEIF(${_INST_PATH} MATCHES /bin/debug$)
156         SET(_ELEM_COMPONENT examples_debug)
157       ELSEIF(${_INST_PATH} MATCHES /CSM/)
158         SET(_ELEM_COMPONENT app_data)
159       ELSE()
160         SET(_ELEM_COMPONENT example_projects)
161       ENDIF()
162     ENDIF()
164 #    MESSAGE("SHARE : ${_SHARE_ELEM} ${_ELEM_COMPONENT} ${_INST_PATH}")
166     INSTALL(FILES ${_BASE_INSTALL_DIR}/${_SHARE_ELEM}
167                   DESTINATION ${_INST_PATH}
168                   PERMISSIONS OWNER_WRITE OWNER_READ
169                               GROUP_READ
170                               WORLD_READ
171                   COMPONENT ${_ELEM_COMPONENT})
172   ENDIF()
174 ENDFOREACH()
178 STRING(REGEX REPLACE ".*\\.(fc[1-9][0-9])\\..*" "\\1" 
179              _OSG_FC_VERSION ${CMAKE_SYSTEM_VERSION})
181 STRING(REGEX REPLACE ".*\\.(el[1-9])\\..*" "\\1" 
182              _OSG_CO_VERSION ${CMAKE_SYSTEM_VERSION})
184 SET(OSG_HOST_SYSTEM_NAME ${CMAKE_HOST_SYSTEM_NAME})
186 IF(NOT _OSG_FC_VERSION STREQUAL ${CMAKE_SYSTEM_VERSION})
187   SET(OSG_HOST_SYSTEM_NAME ${_OSG_FC_VERSION})
188 ENDIF()
190 IF(NOT _OSG_CO_VERSION STREQUAL ${CMAKE_SYSTEM_VERSION})
191   SET(OSG_HOST_SYSTEM_NAME ${_OSG_CO_VERSION})
192 ENDIF()
194 IF(EXISTS "/etc/os-release" AND OSG_HOST_SYSTEM_NAME STREQUAL ${CMAKE_HOST_SYSTEM_NAME})
195   FILE(READ "/etc/os-release" _OSG_OSRELEASE_CONTENTS)
197   STRING(REGEX REPLACE ".*^NAME=\"([^\"]*)\".*" "\\1" _OSG_OSNAME "${_OSG_OSRELEASE_CONTENTS}")
198   STRING(REGEX REPLACE ".*VERSION_ID=\"([^\"]*)\".*" "\\1" _OSG_OSVERSION "${_OSG_OSRELEASE_CONTENTS}")
199   STRING(TOLOWER ${_OSG_OSNAME} _OSG_OSNAME)
200   STRING(REGEX REPLACE "([0-9][0-9])\\.([0-9][0-9])" "\\1" _OSG_OSMAJOR ${_OSG_OSVERSION})
201   STRING(REGEX REPLACE "([0-9][0-9])\\.([0-9][0-9])" "\\2" _OSG_OSMINOR ${_OSG_OSVERSION})
203   SET(OSG_HOST_SYSTEM_NAME "0${_OSG_OSNAME}1_${_OSG_OSMAJOR}_${_OSG_OSMINOR}")
204 ENDIF()
206 SET(SYSTEM_SPEC ${OSG_HOST_SYSTEM_NAME}.${CMAKE_HOST_SYSTEM_PROCESSOR})
209 SET(CPACK_PACKAGE_NAME                "OpenSG")
210 SET(CPACK_PACKAGE_VERSION             @OSG_VERSION@)
211 SET(CPACK_PACKAGE_VERSION_MAJOR       @OSG_VERSION_MAJOR@)
212 SET(CPACK_PACKAGE_VERSION_MINOR       @OSG_VERSION_MINOR@)
213 SET(CPACK_PACKAGE_VERSION_PATCH       @OSG_VERSION_PATCH@)
214 SET(CPACK_PACKAGE_VENDOR              "OpenSG")
215 SET(CPACK_PACKAGE_CONTACT             "Dirk Reiners <dirk@www.opensg.org>")
216 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenSG provides the OpenSG scene graph system")
217 SET(CPACK_RESOURCE_FILE_LICENSE       "${_BASE_INSTALL_DIR}/share/doc/OpenSG/COPYING")
219 SET(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP)
221 IF(NOT OSG_SINGLE_PACKAGE)
222   SET(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
223   SET(CPACK_RPM_COMPONENT_INSTALL     ON)
224 ENDIF()
226 # Date macro by Benoit RAT (www.neub.co.nr)
227 MACRO (TODAY RESULT)
228   IF (WIN32)
229     EXECUTE_PROCESS(COMMAND "date /T" OUTPUT_VARIABLE ${RESULT})
230     string(REGEX REPLACE "(..)/(..)/..(..).*" "\\3\\2\\1" "${RESULT}" "${${RESULT}}")
231   ELSEIF(UNIX)
232     EXECUTE_PROCESS(COMMAND "date" "+%d_%m_%Y" OUTPUT_VARIABLE ${RESULT})
233 #    string(REGEX REPLACE "(..)_(..)_..(..).*" "\\1_\\2_\\3" "${RESULT}" "${${RESULT}}")
234     string(REGEX REPLACE "\n" "" "${RESULT}" "${${RESULT}}")
235   ELSE (WIN32)
236     MESSAGE(SEND_ERROR "date not implemented")
237     SET(${RESULT} 000000)
238   ENDIF (WIN32)
239 ENDMACRO (TODAY)
241 IF(OSG_BUILD_DATE)
242   SET(DATE ${OSG_BUILD_DATE})
243 ELSE()
244   TODAY(DATE)
245 ENDIF()
247 SET(CPACK_PACKAGE_FILE_NAME           "OpenSG.@OSG_VERSION@.${DATE}.${SYSTEM_SPEC}")
249 #MESSAGE("CPFN : ${CPACK_PACKAGE_FILE_NAME}")
251 # Determine package type
252 IF(NOT OSGBUILD_PACKAGE_TYPE OR OSGBUILD_PACKAGE_TYPE STREQUAL "")
253   IF(WIN32)
254     SET(OSGBUILD_PACKAGE_TYPE "ZIP")
255   ELSE(WIN32)
256     SET(OSGBUILD_PACKAGE_TYPE "TBZ2")
257   ENDIF(WIN32)
258 ENDIF(NOT OSGBUILD_PACKAGE_TYPE OR OSGBUILD_PACKAGE_TYPE STREQUAL "")
260 STRING(TOUPPER ${OSGBUILD_PACKAGE_TYPE} CPACK_GENERATOR)
262 SET(CPACK_COMPONENTS_ALL libraries
263                          libraries_debug
265                          headers
266                          development_tools
267                          
268                          python
269                          python_debug
271                          apps
272                          app_data
273                          apps_debug
275 #doc
277                         examples_rel
278                         examples_debug
279                         example_projects)
281 SET(CPACK_COMPONENT_GROUP_RUNTIME_DESCRIPTION        "Suport Files needed to execute software with OpenSG.")
282 SET(CPACK_COMPONENT_GROUP_DEVEL_DESCRIPTION          "Development files needed to develop software with OpenSG.")
283 SET(CPACK_COMPONENT_GROUP_PYTHONDEBUG_DESCRIPTION    "Development files needed to debug OpenSG bindings.")
284 SET(CPACK_COMPONENT_GROUP_EXAMPLES_DESCRIPTION       "Development Examples files needed to develop software with OpenSG.")
286 SET(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME           "Release Runtime Libs")
287 SET(CPACK_COMPONENT_LIBRARIES_DESCRIPTION            "Release Runtime Libraries Description")
288 SET(CPACK_COMPONENT_LIBRARIES_GROUP                  "runtime")
289 SET(CPACK_COMPONENT_LIBRARIES_INSTALL_TYPES          Full Developer Runtime)
291 SET(CPACK_COMPONENT_APPS_DISPLAY_NAME                "Release Runtime Apps")
292 SET(CPACK_COMPONENT_APPS_DESCRIPTION                 "Release Runtime Apps Description")
293 SET(CPACK_COMPONENT_APPS_GROUP                       "runtime")
294 SET(CPACK_COMPONENT_APPS_INSTALL_TYPES               Full Developer Runtime)
296 SET(CPACK_COMPONENT_APP_DATA_DISPLAY_NAME            "Release Runtime App Data")
297 SET(CPACK_COMPONENT_APP_DATA_DESCRIPTION             "Release Runtime App Data Description")
298 SET(CPACK_COMPONENT_APP_DATA_GROUP                   "runtime")
299 SET(CPACK_COMPONENT_APP_DATA_INSTALL_TYPES           Full Developer Runtime)
301 SET(CPACK_COMPONENT_PYHTON_DISPLAY_NAME              "Release Runtime Python")
302 SET(CPACK_COMPONENT_PYTHON_DESCRIPTION               "Release Runtime Python Description")
303 SET(CPACK_COMPONENT_PYTHON_GROUP                     "runtime")
304 SET(CPACK_COMPONENT_PYTHON_INSTALL_TYPES             Full Developer Runtime)
306 SET(CPACK_COMPONENT_LIBRARIES_DEBUG_DISPLAY_NAME     "Debug Runtime Libs")
307 SET(CPACK_COMPONENT_LIBRARIES_DEBUG_DESCRIPTION      "Debug Runtimes Libraries Description")
308 SET(CPACK_COMPONENT_LIBRARIES_DEBUG_GROUP            "devel")
309 SET(CPACK_COMPONENT_LIBRARIES_DEBUG_INSTALL_TYPES    Full Developer Runtime)
311 SET(CPACK_COMPONENT_APPS_DEBUG_DISPLAY_NAME          "Debug Runtime Apps")
312 SET(CPACK_COMPONENT_APPS_DEBUG_DESCRIPTION           "Debug Runtimes Apps Description")
313 SET(CPACK_COMPONENT_APPS_DEBUG_GROUP                 "devel")
314 SET(CPACK_COMPONENT_APPS_DEBUG_INSTALL_TYPES         Full Developer Runtime)
316 SET(CPACK_COMPONENT_PYTHON_DEBUG_DISPLAY_NAME        "Debug Runtime Python")
317 SET(CPACK_COMPONENT_PYTHON_DEBUG_DESCRIPTION         "Debug Runtimes Python Description")
318 SET(CPACK_COMPONENT_PYTHON_DEBUG_GROUP               "pythondebug")
319 SET(CPACK_COMPONENT_PYTHON_DEBUG_INSTALL_TYPES       Full Developer Runtime)
321 SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME             "Headers")
322 SET(CPACK_COMPONENT_HEADERS_DESCRIPTION              "Headers Description")
323 SET(CPACK_COMPONENT_HEADERS_GROUP                    "devel")
324 SET(CPACK_COMPONENT_HEADER_INSTALL_TYPES             Full Developer)
326 SET(CPACK_COMPONENT_DEVELOPMENT_TOOLS_DISPLAY_NAME   "Dev Tools")
327 SET(CPACK_COMPONENT_DEVELOPMENT_TOOLS_DESCRIPTION    "Dev Tools Description")
328 SET(CPACK_COMPONENT_DEVELOPMENT_TOOLS_GROUP          "devel")
329 SET(CPACK_COMPONENT_DEVELOPMENT_TOOLS_INSTALL_TYPES  Full Developer)
332 SET(CPACK_COMPONENT_EXAMPLES_REL_DISPLAY_NAME        "Examples")
333 SET(CPACK_COMPONENT_EXAMPLES_REL_DESCRIPTION         "Examples Description")
334 SET(CPACK_COMPONENT_EXAMPLES_REL_GROUP               "examples")
335 SET(CPACK_COMPONENT_EXAMPLES_REL_INSTALL_TYPES       Full Developer Runtime)
337 SET(CPACK_COMPONENT_EXAMPLES_DEBUG_DISPLAY_NAME      "Examples")
338 SET(CPACK_COMPONENT_EXAMPLES_DEBUG_DESCRIPTION       "Examples Description")
339 SET(CPACK_COMPONENT_EXAMPLES_DEBUG_GROUP             "examples")
340 SET(CPACK_COMPONENT_EXAMPLES_DEBUG_INSTALL_TYPES     Full Developer Runtime)
342 SET(CPACK_COMPONENT_EXAMPLE_PROJECTS_DISPLAY_NAME    "Examples")
343 SET(CPACK_COMPONENT_EXAMPLE_PROJECTS_DESCRIPTION     "Examples Description")
344 SET(CPACK_COMPONENT_EXAMPLE_PROJECTS_GROUP           "examples")
345 SET(CPACK_COMPONENT_EXAMPLE_PROJECTS_INSTALL_TYPES   Full Developer Runtime)
348 IF(CPACK_GENERATOR STREQUAL "RPM")
349   SET(CPACK_RPM_PACKAGE_NAME ${CPACK_PACKAGE_NAME})
350   SET(CPACK_RPM_PACKAGE_REQUIRES "OpenSGSupport-runtime >= 2.0.0, boost >= 1.46.0, expat >= 2.1.0, libxml2 >= 2.7.8, zlib >= 1.2.5")
351   SET(CPACK_RPM_devel_PACKAGE_REQUIRES "OpenSG-runtime >= 2.0.0, OpenSG-devel >= 2.0.0 boost-devel >= 1.46.0, expat-devel >= 2.1.0, libxml2-devel >= 2.7.8, zlib-devel >= 1.2.5")
352   SET(CPACK_PACKAGING_INSTALL_PREFIX    "/usr/local")
354   SET(CPACK_RPM_PACKAGE_LICENSE "LGPL v2, except some contrib packages, check <install_root>/share/doc/OpenSG")
355 ENDIF()
357 INCLUDE(CPack)