fixed: auto_ptr -> unique_ptr
[opensg.git] / Support / CMakeLists.packaging.unix.txt
blob3e6d738b64d60401c94cd90f98072ab2375ba2d5
2 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
4 PROJECT(OpenSGSupportPack)
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 /debug$)
64     SET(_ELEM_COMPONENT libraries_debug)
65   ENDIF()
67 #  MESSAGE("LIB : ${_LIB_ELEM} ${_ELEM_COMPONENT} ${_INST_PATH}")
69   INSTALL(FILES ${_BASE_INSTALL_DIR}/${_LIB_ELEM}
70                 DESTINATION ${_INST_PATH}
71                 PERMISSIONS OWNER_WRITE OWNER_READ
72                             GROUP_READ
73                             WORLD_READ
74                 COMPONENT ${_ELEM_COMPONENT})
76 ENDFOREACH()
78 ################
79 # share
80 ################
82 FILE(GLOB_RECURSE _${PROJECT_NAME}_SHARE
83                   RELATIVE ${_BASE_INSTALL_DIR}
84                   ${_BASE_INSTALL_DIR}/share/*)
86 #MESSAGE("SHARE IN : ${_${PROJECT_NAME}_SHARE}")
88 FOREACH(_SHARE_ELEM ${_${PROJECT_NAME}_SHARE})
90   STRING(REGEX REPLACE /[^/]*$ "" _INST_PATH ${_SHARE_ELEM})
92   SET(_ELEM_COMPONENT libraries)
94   IF(NOT ${_INST_PATH} MATCHES /Packaging)
96 #    MESSAGE("SHARE : ${_SHARE_ELEM} ${_ELEM_COMPONENT} ${_INST_PATH}")
98     INSTALL(FILES ${_BASE_INSTALL_DIR}/${_SHARE_ELEM}
99                   DESTINATION ${_INST_PATH}
100                   PERMISSIONS OWNER_WRITE OWNER_READ
101                               GROUP_READ
102                               WORLD_READ
103                   COMPONENT ${_ELEM_COMPONENT})
104   ENDIF()
106 ENDFOREACH()
108 ################
109 # bin
110 ################
112 FILE(GLOB_RECURSE _${PROJECT_NAME}_BIN
113                   RELATIVE ${_BASE_INSTALL_DIR}
114                   ${_BASE_INSTALL_DIR}/bin/*)
117 FOREACH(_BIN_ELEM ${_${PROJECT_NAME}_BIN})
119   STRING(REGEX REPLACE /[^/]*$ "" _INST_PATH ${_BIN_ELEM})
121   SET(_ELEM_COMPONENT development_tools)
123 #  MESSAGE("BIN : ${_BIN_ELEM} ${_ELEM_COMPONENT} ${_INST_PATH}")
125   INSTALL(FILES ${_BASE_INSTALL_DIR}/${_BIN_ELEM}
126                 DESTINATION ${_INST_PATH}
127                 PERMISSIONS OWNER_WRITE OWNER_READ
128                             GROUP_READ
129                             WORLD_READ
130                 COMPONENT ${_ELEM_COMPONENT})
132 ENDFOREACH()
134 STRING(REGEX REPLACE ".*\\.(fc[1-9][0-9])\\..*" "\\1" 
135              _OSG_FC_VERSION ${CMAKE_SYSTEM_VERSION})
137 STRING(REGEX REPLACE ".*\\.(el[1-9])\\..*" "\\1" 
138              _OSG_CO_VERSION ${CMAKE_SYSTEM_VERSION})
140 SET(OSG_HOST_SYSTEM_NAME ${CMAKE_HOST_SYSTEM_NAME})
142 IF(NOT _OSG_FC_VERSION STREQUAL ${CMAKE_SYSTEM_VERSION})
143   SET(OSG_HOST_SYSTEM_NAME ${_OSG_FC_VERSION})
144 ENDIF()
146 IF(NOT _OSG_CO_VERSION STREQUAL ${CMAKE_SYSTEM_VERSION})
147   SET(OSG_HOST_SYSTEM_NAME ${_OSG_CO_VERSION})
148 ENDIF()
150 IF(EXISTS "/etc/os-release" AND OSG_HOST_SYSTEM_NAME STREQUAL ${CMAKE_HOST_SYSTEM_NAME})
151   FILE(READ "/etc/os-release" _OSG_OSRELEASE_CONTENTS)
153   STRING(REGEX REPLACE ".*^NAME=\"([^\"]*)\".*" "\\1" _OSG_OSNAME "${_OSG_OSRELEASE_CONTENTS}")
154   STRING(REGEX REPLACE ".*VERSION_ID=\"([^\"]*)\".*" "\\1" _OSG_OSVERSION "${_OSG_OSRELEASE_CONTENTS}")
155   STRING(TOLOWER ${_OSG_OSNAME} _OSG_OSNAME)
156   STRING(REGEX REPLACE "([0-9][0-9])\\.([0-9][0-9])" "\\1" _OSG_OSMAJOR ${_OSG_OSVERSION})
157   STRING(REGEX REPLACE "([0-9][0-9])\\.([0-9][0-9])" "\\2" _OSG_OSMINOR ${_OSG_OSVERSION})
159   SET(OSG_HOST_SYSTEM_NAME "0${_OSG_OSNAME}1_${_OSG_OSMAJOR}_${_OSG_OSMINOR}")
160 ENDIF()
162 SET(SYSTEM_SPEC ${OSG_HOST_SYSTEM_NAME}.${CMAKE_HOST_SYSTEM_PROCESSOR})
165 SET(CPACK_PACKAGE_NAME                "OpenSGSupport")
166 SET(CPACK_PACKAGE_VERSION             @OSG_VERSION@)
167 SET(CPACK_PACKAGE_VERSION_MAJOR       @OSG_VERSION_MAJOR@)
168 SET(CPACK_PACKAGE_VERSION_MINOR       @OSG_VERSION_MINOR@)
169 SET(CPACK_PACKAGE_VERSION_PATCH       @OSG_VERSION_PATCH@)
170 SET(CPACK_PACKAGE_VENDOR              "OpenSG")
171 SET(CPACK_PACKAGE_CONTACT             "Dirk Reiners <dirk@www.opensg.org>")
172 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenSGSupport provides the third party libraries OpenSG uses")
173 SET(CPACK_RESOURCE_FILE_LICENSE       "${_BASE_INSTALL_DIR}/share/doc/OpenSG/COPYING.support")
175 SET(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP)
177 IF(NOT OSG_SINGLE_PACKAGE)
178   SET(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
179   SET(CPACK_RPM_COMPONENT_INSTALL     ON)
180 ENDIF()
182 # Date macro by Benoit RAT (www.neub.co.nr)
183 MACRO (TODAY RESULT)
184   IF (WIN32)
185     EXECUTE_PROCESS(COMMAND "date /T" OUTPUT_VARIABLE ${RESULT})
186     string(REGEX REPLACE "(..)/(..)/..(..).*" "\\3\\2\\1" "${RESULT}" "${${RESULT}}")
187   ELSEIF(UNIX)
188     EXECUTE_PROCESS(COMMAND "date" "+%d_%m_%Y" OUTPUT_VARIABLE ${RESULT})
189 #    string(REGEX REPLACE "(..)_(..)_..(..).*" "\\1_\\2_\\3" "${RESULT}" "${${RESULT}}")
190     string(REGEX REPLACE "\n" "" "${RESULT}" "${${RESULT}}")
191   ELSE (WIN32)
192     MESSAGE(SEND_ERROR "date not implemented")
193     SET(${RESULT} 000000)
194   ENDIF (WIN32)
195 ENDMACRO (TODAY)
197 IF(OSG_BUILD_DATE)
198   SET(DATE ${OSG_BUILD_DATE})
199 ELSE()
200   TODAY(DATE)
201 ENDIF()
203 SET(CPACK_PACKAGE_FILE_NAME           "OpenSGSupport.@OSG_VERSION@.${DATE}.${SYSTEM_SPEC}")
205 #MESSAGE("CPFN : ${CPACK_PACKAGE_FILE_NAME}")
207 # Determine package type
208 IF(NOT OSGBUILD_PACKAGE_TYPE OR OSGBUILD_PACKAGE_TYPE STREQUAL "")
209   IF(WIN32)
210     SET(OSGBUILD_PACKAGE_TYPE "ZIP")
211   ELSE(WIN32)
212     SET(OSGBUILD_PACKAGE_TYPE "TBZ2")
213   ENDIF(WIN32)
214 ENDIF(NOT OSGBUILD_PACKAGE_TYPE OR OSGBUILD_PACKAGE_TYPE STREQUAL "")
216 STRING(TOUPPER ${OSGBUILD_PACKAGE_TYPE} CPACK_GENERATOR)
218 SET(CPACK_COMPONENTS_ALL libraries
219                          libraries_debug
221                          headers
222                          development_tools)
224 SET(CPACK_COMPONENT_GROUP_RUNTIME_DESCRIPTION        "Suport Files needed to execute software with OpenSG.")
225 SET(CPACK_COMPONENT_GROUP_DEVEL_DESCRIPTION          "Development support files needed to develop software with OpenSG.")
227 SET(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME           "Support Release Runtime")
228 SET(CPACK_COMPONENT_LIBRARIES_DESCRIPTION            "Support Release Runtime Libraries Description")
229 SET(CPACK_COMPONENT_LIBRARIES_GROUP                  "runtime")
230 SET(CPACK_COMPONENT_LIBRARIES_INSTALL_TYPES          Full Developer Runtime)
232 SET(CPACK_COMPONENT_LIBRARIES_DEBUG_DISPLAY_NAME     "Support Debug Runtime")
233 SET(CPACK_COMPONENT_LIBRARIES_DEBUG_DESCRIPTION      "Support Debug Runtimes Libraries Description")
234 SET(CPACK_COMPONENT_LIBRARIES_DEBUG_GROUP            "devel")
235 SET(CPACK_COMPONENT_LIBRARIES_DEBUG_INSTALL_TYPES    Full Developer Runtime)
237 SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME             "Support Headers")
238 SET(CPACK_COMPONENT_HEADERS_DESCRIPTION              "Support Headers Description")
239 SET(CPACK_COMPONENT_HEADERS_GROUP                    "devel")
240 SET(CPACK_COMPONENT_HEADER_INSTALL_TYPES             Full Developer)
242 SET(CPACK_COMPONENT_DEVELOPMENT_TOOLS_DISPLAY_NAME   "Support Dev Tools")
243 SET(CPACK_COMPONENT_DEVELOPMENT_TOOLS_DESCRIPTION    "Support Dev Tools Description")
244 SET(CPACK_COMPONENT_DEVELOPMENT_TOOLS_GROUP          "devel")
245 SET(CPACK_COMPONENT_DEVELOPMENT_TOOLS_INSTALL_TYPES  Full Developer)
247 IF(CPACK_GENERATOR STREQUAL "RPM")
248   SET(CPACK_RPM_PACKAGE_NAME ${CPACK_PACKAGE_NAME})
249   SET(CPACK_RPM_PACKAGE_REQUIRES "boost >= 1.46.0, expat >= 2.1.0, libxml2 >= 2.7.8, zlib >= 1.2.5")
250   SET(CPACK_RPM_devel_PACKAGE_REQUIRES "OpenSGSupport-runtime >= 2.0.0, boost-devel >= 1.46.0,  expat-devel >= 2.1.0, libxml2-devel >= 2.7.8, zlib-devel >= 1.2.5")
251   SET(CPACK_PACKAGING_INSTALL_PREFIX    "/usr/local")
253   SET(CPACK_RPM_PACKAGE_LICENSE "Individual package licenses, see <install_root>/share/doc/OpenSG/COPYING.support")
254 ENDIF()
256 INCLUDE(CPack)