From Mattias Helsing, "got some feedback from J-S on the packaging so I have changed the

name of the top folder in each package to OpenSceneGraph-x.y.z

Noone else has had an opinion on whether compiler and it's version
should be part of the package filename on their platform/setup so I'll
leave it as is. That is - No action is taken for compilers other than
msvc but one can easily add this information to the cmake cache
regardless of platform.
"
This commit is contained in:
Robert Osfield 2009-01-21 18:34:10 +00:00
parent 908432c732
commit a3b91f9294
4 changed files with 126 additions and 75 deletions

View File

@ -742,10 +742,9 @@ IF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE)
SET(OSG_CONFIG_HAS_BEEN_RUN_BEFORE 1 CACHE INTERNAL "Flag to track whether this is the first time running CMake or if CMake has been configured before")
ENDIF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE)
# CPack is only available for cmake version >= 2.6.0
# present the packaging option only if we have the cpack command defined (effectively >= 2.6.0)
IF(CMAKE_CPACK_COMMAND)
# If CMake >= 2.6.0
OPTION(BUILD_OSG_PACKAGES "Set to ON to generate CPack configuration files and default packaging targets" OFF)
OPTION(BUILD_OSG_PACKAGES "Set to ON to generate CPack configuration files and packaging targets" OFF)
IF(BUILD_OSG_PACKAGES)
INCLUDE(OsgCPack)
ENDIF(BUILD_OSG_PACKAGES)

View File

@ -1,6 +1,13 @@
# This script sets up packaging targets for each "COMPONENT" as specified in INSTALL commands
#
# collect a descriptive system specification string <system>-<arch>-<compiler>
# for each component a CPackConfig-<component>.cmake is generated in the build tree
# and a target is added to call cpack for it (e.g. package_openscenegaph
# A target for generating a package with everything that gets INSTALLED is generated (package_openscenegraph-all)
# A target for making all of the abaove packages is generated (package_ALL)
#
# package filenames are created on the form <package>-<platform>-<arch>[-<compiler>]-<build_type>[-static].tar.gz
# ...where compiler optionally set using a cmake gui (OSG_CPACK_COMPILER). This script tries to guess compiler version for msvc generators
# ...build_type matches CMAKE_BUILD_TYPE for all generators but the msvc ones
# resolve architecture. The reason i "change" i686 to i386 is that debian packages
# require i386 so this is for the future
@ -15,51 +22,21 @@ SET(SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
#message(STATUS "CMAKE_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}")
#message(STATUS "CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR}")
# Platform specific settings.
# Includes setting the compiler and specifying debug/release build
# for windows the SYSTEM_NAME is set win32/64 instead of windows
# for msvc the SYSTEM_NAME is set win32/64 instead of "Windows"
IF(MSVC)
#Visual C++, 32-bit, version 6.0 1200
#Visual C++, 32-bit, version .net 2002 1300
#Visual C++, 32-bit, version .net 2003 1310
#Visual C++, 32-bit, version 2005 1400 (vc80)
#Visual C++, 32-bit, version 2005 SP1 1400 (vc80_sp1)
#Visual C++, 32-bit, version 2008 1500 (vc90)
IF(MSVC_VERSION EQUAL 1500)
SET(OSG_CPACK_COMPILER "vc90")
ELSE(MSVC_VERSION EQUAL 1500)
# This if doesn't detect my 2005 vc80sp1 compiler. Have to rely on COMPILER_2005
IF(MSVC_VERSION EQUAL 1400)
SET(OSG_CPACK_COMPILER "vc80")
ELSE(MSVC_VERSION EQUAL 1400)
IF(CMAKE_COMPILER_2005)
SET(OSG_CPACK_COMPILER "vc80")
ENDIF(CMAKE_COMPILER_2005)
ENDIF(MSVC_VERSION EQUAL 1400)
ENDIF(MSVC_VERSION EQUAL 1500)
IF(MSVC_VERSION EQUAL 1310)
SET(OSG_CPACK_COMPILER "vc70")
ENDIF(MSVC_VERSION EQUAL 1310)
# check arch bitcount
IF(CMAKE_CL_64)
SET(SYSTEM_NAME "win64")
ELSE(CMAKE_CL_64)
SET(SYSTEM_NAME "win32")
ENDIF(CMAKE_CL_64)
ELSE(MSVC)
# on un*x an empty CMAKE_BUILD_TYPE means release
IF(CMAKE_BUILD_TYPE)
SET(SYSTEM_BUILD_TYPE ${CMAKE_BUILD_TYPE})
ELSE(CMAKE_BUILD_TYPE)
SET(SYSTEM_BUILD_TYPE "Release")
ENDIF(CMAKE_BUILD_TYPE)
ENDIF(MSVC)
# Guess the compiler (is this desired for other platforms than windows?)
IF(NOT DEFINED OSG_CPACK_COMPILER)
INCLUDE(OsgDetermineCompiler)
ENDIF(NOT DEFINED OSG_CPACK_COMPILER)
# expose the compiler setting to the user
SET(OSG_CPACK_COMPILER "${OSG_CPACK_COMPILER}" CACHE STRING "This ia short string (vc90, vc80sp1, gcc-4.3, ...) describing your compiler. The string is used for creating package filenames")
SET(OSG_CPACK_COMPILER "${OSG_COMPILER}" CACHE STRING "This ia short string (vc90, vc80sp1, gcc-4.3, ...) describing your compiler. The string is used for creating package filenames")
IF(OSG_CPACK_COMPILER)
SET(OSG_CPACK_SYSTEM_SPEC_STRING ${SYSTEM_NAME}-${SYSTEM_ARCH}-${OSG_CPACK_COMPILER})
@ -69,41 +46,35 @@ ENDIF(OSG_CPACK_COMPILER)
## variables that apply to all packages
SET(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
#SET(CPACK_PACKAGE_FILE_NAME "openscenegraph-all-${OPENSCENEGRAPH_VERSION}-${OSG_CPACK_SYSTEM_SPEC_STRING}")
SET(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The OpenSceneGraph is an open source high performance 3d graphics toolkit")
SET(CPACK_PACKAGE_VENDOR "The OpenSceneGraph developers and contributors lead by Robert Osfield")
SET(CPACK_PACKAGE_VERSION_MAJOR ${OPENSCENEGRAPH_MAJOR_VERSION})
SET(CPACK_PACKAGE_VERSION_MINOR ${OPENSCENEGRAPH_MINOR_VERSION})
SET(CPACK_PACKAGE_VERSION_PATCH ${OPENSCENEGRAPH_PATCH_VERSION})
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "OpenSceneGraph-${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}")
SET(CPACK_TOPLEVEL_TAG ${CPACK_PACKAGE_NAME}-${OPENSCENEGRAPH_VERSION})
SET(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${OPENSCENEGRAPH_VERSION}")
# these goes for all platforms. Setting these stops the CPack.cmake script from generating options about other package compression formats (.z .tz, etc.)
SET(CPACK_GENERATOR "TGZ")
SET(CPACK_SOURCE_GENERATOR "TGZ")
# for msvc we use it's internally defined variable to get the configuration (debug,release, ...)
IF(MSVC)
# for ms visual studio we use it's internally defined variable to get the configuration (debug,release, ...)
IF(MSVC_IDE)
SET(OSG_CPACK_CONFIGURATION "$(OutDir)")
SET(PACKAGE_TARGET_PREFIX "Package ")
ELSE(MSVC)
SET(OSG_CPACK_CONFIGURATION "${SYSTEM_BUILD_TYPE}")
ELSE(MSVC_IDE)
# on un*x an empty CMAKE_BUILD_TYPE means release
IF(CMAKE_BUILD_TYPE)
SET(OSG_CPACK_CONFIGURATION ${CMAKE_BUILD_TYPE})
ELSE(CMAKE_BUILD_TYPE)
SET(OSG_CPACK_CONFIGURATION "Release")
ENDIF(CMAKE_BUILD_TYPE)
SET(PACKAGE_TARGET_PREFIX "package_")
ENDIF(MSVC)
ENDIF(MSVC_IDE)
# Get all defined components
IF(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION GREATER 4 AND CMAKE_PATCH_VERSION GREATER 0)
GET_CMAKE_PROPERTY(CPACK_COMPONENTS_ALL COMPONENTS)
ELSE(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION GREATER 4 AND CMAKE_PATCH_VERSION GREATER 0)
# cmake 2.6.0 didn't supply the COMPONENTS property.
GET_CMAKE_PROPERTY(CPACK_COMPONENTS_ALL COMPONENTS)
IF(NOT CPACK_COMPONENTS_ALL)
# cmake 2.6.0 don't supply the COMPONENTS property.
# I set it manually to be the packages that can always be packaged
MESSAGE("When building packages please consider using cmake version 2.6.1 or above")
SET(CPACK_COMPONENTS_ALL libopenscenegraph openscenegraph libopenthreads libopenscenegraph-dev libopenthreads-dev)
ENDIF(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION GREATER 4 AND CMAKE_PATCH_VERSION GREATER 0)
SET(CPACK_COMPONENTS_ALL libopenscenegraph libopenthreads openscenegraph libopenscenegraph-dev libopenthreads-dev)
ENDIF(NOT CPACK_COMPONENTS_ALL)
# Create a target that will be used to generate all packages defined below
SET(PACKAGE_ALL_TARGETNAME "${PACKAGE_TARGET_PREFIX}ALL")
@ -117,21 +88,15 @@ MACRO(GENERATE_PACKAGING_TARGET package_name)
SET(OSG_PACKAGE_FILE_NAME ${package_name}-${OPENSCENEGRAPH_VERSION})
ELSE(${package} MATCHES -doc)
SET(OSG_PACKAGE_FILE_NAME ${package_name}-${OPENSCENEGRAPH_VERSION}-${OSG_CPACK_SYSTEM_SPEC_STRING}-${OSG_CPACK_CONFIGURATION})
IF(NOT DYNAMIC_OPENSCENEGRAPH)
SET(OSG_PACKAGE_FILE_NAME ${OSG_PACKAGE_FILE_NAME}-static)
ENDIF(NOT DYNAMIC_OPENSCENEGRAPH)
ENDIF(${package} MATCHES -doc)
CONFIGURE_FILE("${OpenSceneGraph_SOURCE_DIR}/CMakeModules/OsgCPackConfig.cmake.in" "${OpenSceneGraph_BINARY_DIR}/CPackConfig-${package_name}.cmake" IMMEDIATE)
SET(PACKAGE_TARGETNAME "${PACKAGE_TARGET_PREFIX}${package_name}")
# Create a target that creates the current package
ADD_CUSTOM_TARGET(${PACKAGE_TARGETNAME})
ADD_CUSTOM_COMMAND(TARGET ${PACKAGE_TARGETNAME}
COMMAND ${CMAKE_CPACK_COMMAND} -C ${OSG_CPACK_CONFIGURATION} --config ${OpenSceneGraph_BINARY_DIR}/CPackConfig-${package_name}.cmake
COMMENT "Run CPack packaging for ${package_name}..."
)
ADD_CUSTOM_COMMAND(TARGET ${PACKAGE_ALL_TARGETNAME}
COMMAND ${CMAKE_CPACK_COMMAND} -C ${OSG_CPACK_CONFIGURATION} --config ${OpenSceneGraph_BINARY_DIR}/CPackConfig-${package_name}.cmake
)
# This is naive and will probably need fixing eventually
IF(MSVC)
SET(MOVE_COMMAND "move")
@ -139,15 +104,21 @@ MACRO(GENERATE_PACKAGING_TARGET package_name)
SET(MOVE_COMMAND "mv")
ENDIF(MSVC)
# Rename the package to get the proper filename <package>-<platform>-<arch>[compiler]-<buildtype>.tar.gz
# Create a target that creates the current package
# and rename the package to give it proper filename
ADD_CUSTOM_TARGET(${PACKAGE_TARGETNAME})
ADD_CUSTOM_COMMAND(TARGET ${PACKAGE_TARGETNAME}
# COMMAND "${MOVE_COMMAND}" "${CPACK_PACKAGE_FILE_NAME}.tar.gz" "${OSG_PACKAGE_FILE_NAME}-$(OutDir).tar.gz"
COMMAND ${CMAKE_CPACK_COMMAND} -C ${OSG_CPACK_CONFIGURATION} --config ${OpenSceneGraph_BINARY_DIR}/CPackConfig-${package_name}.cmake
COMMAND "${MOVE_COMMAND}" "${CPACK_PACKAGE_FILE_NAME}.tar.gz" "${OSG_PACKAGE_FILE_NAME}.tar.gz"
COMMAND ${CMAKE_COMMAND} -E echo "renamed ${CPACK_PACKAGE_FILE_NAME}.tar.gz -> ${OSG_PACKAGE_FILE_NAME}.tar.gz"
COMMENT "Run CPack packaging for ${package_name}..."
)
# Add the exact same custom command to the all package generating target.
# I can't use add_dependencies to do this because it would allow parallell building of packages so am going brute here
ADD_CUSTOM_COMMAND(TARGET ${PACKAGE_ALL_TARGETNAME}
COMMAND ${CMAKE_CPACK_COMMAND} -C ${OSG_CPACK_CONFIGURATION} --config ${OpenSceneGraph_BINARY_DIR}/CPackConfig-${package_name}.cmake
COMMAND "${MOVE_COMMAND}" "${CPACK_PACKAGE_FILE_NAME}.tar.gz" "${OSG_PACKAGE_FILE_NAME}.tar.gz"
COMMAND ${CMAKE_COMMAND} -E echo "renamed ${CPACK_PACKAGE_FILE_NAME}.tar.gz -> ${OSG_PACKAGE_FILE_NAME}.tar.gz"
)
ENDMACRO(GENERATE_PACKAGING_TARGET)

View File

@ -59,7 +59,7 @@ SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CMAKE_PROJECT_NAME}-${OPENSCENEGRAPH_VERSION}")
SET(CPACK_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
SET(CPACK_PACKAGE_RELOCATABLE "true")
SET(CPACK_PACKAGE_VENDOR "")
SET(CPACK_PACKAGE_VENDOR "The OpenSceneGraph developers and contributors lead by Robert Osfield")
SET(CPACK_PACKAGE_VERSION "${OPENSCENEGRAPH_VERSION}")
SET(CPACK_PACKAGE_VERSION_MAJOR "${OPENSCENEGRAPH_MAJOR_VERSION}")
SET(CPACK_PACKAGE_VERSION_MINOR "${OPENSCENEGRAPH_MINOR_VERSION}")

View File

@ -0,0 +1,81 @@
# - Figure out what compiler (and version) cmake is generating for
# Once done this will define:
#
# Variable:
# OSG_COMPILER
#
IF(CMAKE_COMPILER_IS_GNUCXX)
EXEC_PROGRAM(
${CMAKE_CXX_COMPILER}
ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
OUTPUT_VARIABLE gcc_compiler_version
)
#MESSAGE("GCC Version: ${gcc_compiler_version}")
ELSE(CMAKE_COMPILER_IS_GNUCXX)
IF(MSVC)
IF(MSVC60)
SET(OSG_COMPILER "vc60")
ENDIF(MSVC60)
IF(MSVC70)
SET(OSG_COMPILER "vc70")
ENDIF(MSVC70)
IF(MSVC71)
SET(OSG_COMPILER "vc71")
ENDIF(MSVC71)
IF(MSVC80)
SET(OSG_COMPILER "vc80")
ENDIF(MSVC80)
IF(MSVC90)
SET(OSG_COMPILER "vc90")
ENDIF(MSVC90)
IF(MSVC80)
MESSAGE(STATUS "Checking if compiler has service pack 1 installed...")
FILE(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx" "int main() {return 0;}\n")
TRY_COMPILE(_TRY_RESULT
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx
CMAKE_FLAGS -D CMAKE_VERBOSE_MAKEFILE=ON
OUTPUT_VARIABLE OUTPUT
)
IF(_TRY_RESULT)
# parse for exact compiler version
STRING(REGEX MATCH "Compiler Version [0-9]+.[0-9]+.[0-9]+.[0-9]+" vc_compiler_version "${OUTPUT}")
IF(vc_compiler_version)
#MESSAGE("${vc_compiler_version}")
STRING(REGEX MATCHALL "[0-9]+" CL_VERSION_LIST "${vc_compiler_version}")
LIST(GET CL_VERSION_LIST 0 CL_MAJOR_VERSION)
LIST(GET CL_VERSION_LIST 1 CL_MINOR_VERSION)
LIST(GET CL_VERSION_LIST 2 CL_PATCH_VERSION)
LIST(GET CL_VERSION_LIST 3 CL_EXTRA_VERSION)
ENDIF(vc_compiler_version)
# Standard vc80 is 14.00.50727.42, sp1 14.00.50727.762, sp2?
# Standard vc90 is 9.0.30729.1, sp1 ?
IF(CL_EXTRA_VERSION EQUAL 762)
SET(OSG_COMPILER "vc80sp1")
ELSE(CL_EXTRA_VERSION EQUAL 762)
SET(OSG_COMPILER "vc80")
ENDIF(CL_EXTRA_VERSION EQUAL 762)
# parse for exact visual studio version
#IF(MSVC_IDE)
# string(REGEX MATCH "Visual Studio Version [0-9]+.[0-9]+.[0-9]+.[0-9]+" vs_version "${OUTPUT}")
# IF(vs_version)
# MESSAGE("${vs_version}")
# string(REGEX MATCHALL "[0-9]+" VS_VERSION_LIST "${vs_version}")
# list(GET VS_VERSION_LIST 0 VS_MAJOR_VERSION)
# list(GET VS_VERSION_LIST 1 VS_MINOR_VERSION)
# list(GET VS_VERSION_LIST 2 VS_PATCH_VERSION)
# list(GET VS_VERSION_LIST 3 VS_EXTRA_VERSION)
# ENDIF(vs_version)
#ENDIF(MSVC_IDE)
ENDIF(_TRY_RESULT)
ENDIF(MSVC80)
ENDIF(MSVC)
ENDIF(CMAKE_COMPILER_IS_GNUCXX)