From Mattias Helsing, "I have developed the earlier cpack example a bit. Perhaps you could

consider these initial cpack support scripts. It is hidden behind a
BUILD_PACKAGES option so won't affect the normal user. The submission
1) set the COMPONENT attribute on all cmake install commands.
COMPONENT names are according to
http://www.openscenegraph.org/projects/osg/wiki/Community/Packaging

2) provide cmake script and a template for creating CPack
configuration files. It will generate target for creating packages
with everything that gets "installed" (make package on unx, project
PACKAGE in MSVC) plus targets for generating one package per COMPONENT
(i.e. libopenscenegraph-core etc.).

I have temporariliy uploaded some examples to
http://www.openscenegraph.org/projects/osg/wiki/Community/People/MattiasHelsing

If this submission makes it into svn we can develop it to generate
rpms, installers for windows and mac (I know at least J-S don't like
these but there may be others who do ;) and even DEBs (not sure if we
can make them "ubuntu-ready" but they eventually may - at least we
could put a deb on the website)"
This commit is contained in:
Robert Osfield 2008-12-12 11:01:09 +00:00
parent 388531e834
commit 55fe4967ad
17 changed files with 198 additions and 29 deletions

View File

@ -691,6 +691,7 @@ IF(BUILD_DOCUMENTATION)
ELSE(DOT)
SET(HAVE_DOT NO)
ENDIF(DOT)
# This processes our Doxyfile.in and substitutes paths to generate
# a final Doxyfile
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/doc/Doxyfiles/doxyfile.cmake
@ -720,6 +721,10 @@ 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)
OPTION(BUILD_PACKAGES "Set to ON to generate CPack configuration files and default packaging targets" OFF)
IF(BUILD_PACKAGES)
INCLUDE(OsgCPack)
ENDIF(BUILD_PACKAGES)
#-----------------------------------------------------------------------------
### uninstall target

View File

@ -22,17 +22,19 @@ SOURCE_GROUP(
)
IF(MSVC AND OSG_MSVC_VERSIONED_DLL)
HANDLE_MSVC_DLL()
HANDLE_MSVC_DLL()
ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
INSTALL(
TARGETS ${LIB_NAME}
RUNTIME DESTINATION ${INSTALL_BINDIR}
LIBRARY DESTINATION ${INSTALL_LIBDIR}
ARCHIVE DESTINATION ${INSTALL_ARCHIVEDIR}
RUNTIME DESTINATION ${INSTALL_BINDIR} COMPONENT libopenscenegraph-core
LIBRARY DESTINATION ${INSTALL_LIBDIR} COMPONENT libopenscenegraph-core
ARCHIVE DESTINATION ${INSTALL_ARCHIVEDIR} COMPONENT libopenscenegraph-core-dev
)
# FIXME: Do not run for OS X framework
INSTALL(
FILES ${LIB_PUBLIC_HEADERS}
DESTINATION ${INSTALL_INCDIR}/${LIB_NAME}
COMPONENT libopenscenegraph-core-dev
)

View File

@ -0,0 +1,79 @@
## variables that apply to all packages
SET(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
SET(CPACK_PACKAGE_FILE_NAME "openscenegraph-${OPENSCENEGRAPH_VERSION}")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The OpenSceneGraph is an open source high performance 3d graphics toolkit")
SET(CPACK_PACKAGE_VENDOR "The OpenSceneGraph authors")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${OpenSceneGraph_SOURCE_DIR}/README.txt")
SET(CPACK_RESOURCE_FILE_LICENSE "${OpenSceneGraph_SOURCE_DIR}/LICENSE.txt")
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_SOURCE_TOPLEVEL_TAG ${CPACK_PACKAGE_NAME}-${OPENSCENEGRAPH_VERSION}-src)
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "openscenegraph-${OPENSCENEGRAPH_VERSION}-src")
# Add the build directory to the ignore patterns and expose var to the users
# N.B. This is especially important if your are building out-of-source but under the source tree (i.e <OpenSceneGraphSrcDir>/build).
# If you don't name your builddir here it will get pulled into the src package. Size of my build tree is gigabytes so you dont want this
SET(CPACK_SOURCE_IGNORE_FILES "/\\\\\\\\.svn/;\\\\\\\\.swp$;\\\\\\\\.#;/#;build" CACHE STRING "Add ignore patterns that will left out of the src package")
# platform specifics. Per default generate zips on win32 and tgz's on unix
IF(APPLE)
# don't really know how to do it on the MAC yet
ELSE(APPLE)
IF(WIN32 AND NOT UNIX)
OPTION(BUILD_NSIS_PACKAGE "Turn this ON if you want to generate a visual installer using NSIS (nsis.sourceforge.net)" OFF)
IF(BUILD_NSIS_PACKAGE)
# There is a bug in NSIS that does not handle full unix paths properly. Make
# sure there is at least one set of four (4) backlasshes.
SET(CPACK_PACKAGE_ICON "${OpenSceneGraph_SOURCE_DIR}/PlatformSpecifics/Windows/icons\\\\osg.ico")
SET(CPACK_NSIS_INSTALLED_ICON_NAME "")
SET(CPACK_NSIS_DISPLAY_NAME "OpenSceneGraph ${OPENSCENEGRAPH_VERSION}")
SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.openscenegraph.org/projects/osg/wiki/Support")
SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.openscenegraph.org/projects/osg/wiki/About")
SET(CPACK_NSIS_CONTACT "")
SET(CPACK_NSIS_MODIFY_PATH ON)
SET(CPACK_GENERATOR "NSIS")
ELSE(BUILD_NSIS_PACKAGE)
SET(CPACK_GENERATOR "ZIP")
ENDIF(BUILD_NSIS_PACKAGE)
ELSE(WIN32 AND NOT UNIX)
SET(CPACK_STRIP_FILES ON)
SET(CPACK_SOURCE_STRIP_FILES ON)
SET(CPACK_GENERATOR "TGZ")
ENDIF(WIN32 AND NOT UNIX)
ENDIF(APPLE)
STRING(TOLOWER "${CMAKE_SYSTEM_NAME}" CPACK_SYSTEM_NAME)
# include CPack will generate CPackConfig.cmake and CPackSourceConfig.cmake
# Including CPack will generate CPackConfig.cmake and CPackSourceConfig.cmake and make targets regardless of how i call it
# The first idea was to not use it at all and that might be where we're going. For now it also defines some useful macros, especially
# for the visual installers, so I decided to include it to have the possibility to create visual installers for ms and mac and then try to
# make the best use I could of the targets that including CPack implies
include(CPack)
# includiong CPack will generate a PACKAGE project on MSVC and package/package_src target on unixes. For MSVC I also create a PACACKGE_SRC
IF(MSVC_IDE)
add_custom_target("PACKAGE-SOURCE"
COMMAND ${CMAKE_CPACK_COMMAND} --config ${OpenSceneGraph_BINARY_DIR}/CPackSourceConfig.cmake
)
ENDIF(MSVC_IDE)
# including CPack also has the benefit of creating this nice var which is a collection of all defined COMPONENTS
# Create configs and targets for each component
FOREACH(package ${CPACK_COMPONENTS_ALL})
set(CPACK_PACKAGE_FILE_NAME ${package}-${OPENSCENEGRAPH_VERSION}-${CPACK_SYSTEM_NAME})
set(OSG_CPACK_COMPONENT ${package})
configure_file("${OpenSceneGraph_SOURCE_DIR}/CMakeModules/OsgCPackConfig.cmake.in" "${OpenSceneGraph_BINARY_DIR}/CPackConfig-${OSG_CPACK_COMPONENT}.cmake" IMMEDIATE)
add_custom_target("package_${package}"
COMMAND ${CMAKE_CPACK_COMMAND} --config ${OpenSceneGraph_BINARY_DIR}/CPackConfig-${OSG_CPACK_COMPONENT}.cmake
COMMENT Run CPack packaging for ${package}...
)
ENDFOREACH(package ${CPACK_COMPONENTS_ALL})

View File

@ -0,0 +1,72 @@
# This file will be configured to contain variables for CPack. These variables
# should be set in the CMake list file of the project before CPack module is
# included. Example variables are:
# CPACK_GENERATOR - Generator used to create package
# CPACK_INSTALL_CMAKE_PROJECTS - For each project (path, name, component)
# CPACK_CMAKE_GENERATOR - CMake Generator used for the projects
# CPACK_INSTALL_COMMANDS - Extra commands to install components
# CPACK_INSTALL_DIRECTORIES - Extra directories to install
# CPACK_PACKAGE_DESCRIPTION_FILE - Description file for the package
# CPACK_PACKAGE_DESCRIPTION_SUMMARY - Summary of the package
# CPACK_PACKAGE_EXECUTABLES - List of pairs of executables and labels
# CPACK_PACKAGE_FILE_NAME - Name of the package generated
# CPACK_PACKAGE_ICON - Icon used for the package
# CPACK_PACKAGE_INSTALL_DIRECTORY - Name of directory for the installer
# CPACK_PACKAGE_NAME - Package project name
# CPACK_PACKAGE_VENDOR - Package project vendor
# CPACK_PACKAGE_VERSION - Package project version
# CPACK_PACKAGE_VERSION_MAJOR - Package project version (major)
# CPACK_PACKAGE_VERSION_MINOR - Package project version (minor)
# CPACK_PACKAGE_VERSION_PATCH - Package project version (patch)
# There are certain generator specific ones
# NSIS Generator:
# CPACK_PACKAGE_INSTALL_REGISTRY_KEY - Name of the registry key for the installer
# CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS - Extra commands used during uninstall
# CPACK_NSIS_EXTRA_INSTALL_COMMANDS - Extra commands used during install
SET(CPACK_BINARY_BUNDLE "${CPACK_BINARY_BUNDLE}")
SET(CPACK_BINARY_CYGWIN "${CPACK_BINARY_CYGWIN}")
SET(CPACK_BINARY_DEB "${CPACK_BINARY_DEB}")
SET(CPACK_BINARY_NSIS "${CPACK_BINARY_NSIS}")
SET(CPACK_BINARY_OSXX11 "${CPACK_BINARY_OSXX11}")
SET(CPACK_BINARY_PACKAGEMAKER "${CPACK_BINARY_PACKAGEMAKER}")
SET(CPACK_BINARY_RPM "${CPACK_BINARY_RPM}")
SET(CPACK_BINARY_STGZ "${CPACK_BINARY_STGZ}")
SET(CPACK_BINARY_TBZ2 "${CPACK_BINARY_TBZ2}")
SET(CPACK_BINARY_TGZ "${CPACK_BINARY_TGZ}")
SET(CPACK_BINARY_TZ "${CPACK_BINARY_TZ}")
SET(CPACK_BINARY_ZIP "${CPACK_BINARY_ZIP}")
SET(CPACK_CMAKE_GENERATOR "${CMAKE_GENERATOR}")
SET(CPACK_COMPONENTS_ALL "${CPACK_COMPONENTS_ALL}")
SET(CPACK_COMPONENT_UNSPECIFIED_HIDDEN "TRUE")
SET(CPACK_COMPONENT_UNSPECIFIED_REQUIRED "TRUE")
SET(CPACK_GENERATOR "${CPACK_GENERATOR}")
SET(CPACK_INSTALL_CMAKE_PROJECTS "${OpenSceneGraph_BINARY_DIR};OpenSceneGraph;${OSG_CPACK_COMPONENT};/")
SET(CPACK_INSTALL_PREFIX "${CPACK_INSTALL_PREFIX}")
SET(CPACK_MODULE_PATH "${OpenSceneGraph_SOURCE_DIR}/CMakeModules;")
SET(CPACK_NSIS_DISPLAY_NAME "${CMAKE_PROJECT_NAME} ${OPENSCENEGRAPH_VERSION}")
SET(CPACK_NSIS_INSTALLER_ICON_CODE "")
SET(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "")
SET(CPACK_OUTPUT_CONFIG_FILE "${PROJECT_BINARY_DIR}/CPackConfig-${OSG_CPACK_COMPONENT}.cmake")
SET(CPACK_PACKAGE_DEFAULT_LOCATION "/")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${OpenSceneGraph_SOURCE_DIR}/README.txt")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The OpenSceneGraph is an open source high performance 3d graphics toolkit")
#SET(CPACK_PACKAGE_EXECUTABLES "osgviewer;The generic viewer")
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CMAKE_PROJECT_NAME}-${OPENSCENEGRAPH_VERSION}")
SET(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
SET(CPACK_PACKAGE_RELOCATABLE "true")
SET(CPACK_PACKAGE_VENDOR "")
SET(CPACK_PACKAGE_VERSION "${OPENSCENEGRAPH_VERSION}")
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_RESOURCE_FILE_LICENSE "${OpenSceneGraph_SOURCE_DIR}/LICENSE.txt")
SET(CPACK_RESOURCE_FILE_README "${OpenSceneGraph_SOURCE_DIR}/README.txt")
SET(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_ROOT}/share/cmake-2.6/Templates/CPack.GenericWelcome.txt")
SET(CPACK_SET_DESTDIR "OFF")
SET(CPACK_STRIP_FILES "ON")

View File

@ -130,6 +130,13 @@ MACRO(SETUP_PLUGIN PLUGIN_NAME)
IF(NOT TARGET_LABEL)
SET(TARGET_LABEL "${TARGET_DEFAULT_LABEL_PREFIX} ${TARGET_NAME}")
ENDIF(NOT TARGET_LABEL)
## plugins gets put in libopenscenegraph by default
IF(${ARGC} GREATER 1)
SET(PACKAGE_COMPONENT libopenscenegraph-${ARGV1})
ELSE(${ARGC} GREATER 1)
SET(PACKAGE_COMPONENT libopenscenegraph)
ENDIF(${ARGC} GREATER 1)
# here we use the command to generate the library
@ -184,14 +191,14 @@ MACRO(SETUP_PLUGIN PLUGIN_NAME)
#the installation path are differentiated for win32 that install in bib versus other architecture that install in lib${LIB_POSTFIX}/${OSG_PLUGINS}
IF(WIN32)
INSTALL(TARGETS ${TARGET_TARGETNAME}
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib/${OSG_PLUGINS}
LIBRARY DESTINATION bin/${OSG_PLUGINS} )
RUNTIME DESTINATION bin COMPONENT ${PACKAGE_COMPONENT}
ARCHIVE DESTINATION lib/${OSG_PLUGINS} COMPONENT libopenscenegraph-dev
LIBRARY DESTINATION bin/${OSG_PLUGINS} COMPONENT ${PACKAGE_COMPONENT})
ELSE(WIN32)
INSTALL(TARGETS ${TARGET_TARGETNAME}
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS}
LIBRARY DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} )
RUNTIME DESTINATION bin COMPONENT ${PACKAGE_COMPONENT}
ARCHIVE DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} COMPONENT libopenscenegraph-dev
LIBRARY DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} COMPONENT ${PACKAGE_COMPONENT})
ENDIF(WIN32)
ENDMACRO(SETUP_PLUGIN)
@ -273,7 +280,7 @@ MACRO(SETUP_APPLICATION APPLICATION_NAME)
IF(APPLE)
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin BUNDLE DESTINATION bin)
ELSE(APPLE)
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin )
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin COMPONENT openscenegraph )
ENDIF(APPLE)
ENDMACRO(SETUP_APPLICATION)
@ -300,7 +307,7 @@ MACRO(SETUP_EXAMPLE EXAMPLE_NAME)
IF(APPLE)
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin BUNDLE DESTINATION share/OpenSceneGraph/bin )
ELSE(APPLE)
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin )
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin COMPONENT libopenscenegraph-examples )
ENDIF(APPLE)
ENDMACRO(SETUP_EXAMPLE)

View File

@ -105,13 +105,14 @@ LINK_DIRECTORIES(
INSTALL(
TARGETS OpenThreads
ARCHIVE DESTINATION lib${LIB_POSTFIX}
LIBRARY DESTINATION lib${LIB_POSTFIX}
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib${LIB_POSTFIX} COMPONENT libopenthreads
LIBRARY DESTINATION lib${LIB_POSTFIX} COMPONENT libopenthreads
RUNTIME DESTINATION bin COMPONENT libopenthreads
)
INSTALL(
FILES ${OpenThreads_PUBLIC_HEADERS}
DESTINATION include/OpenThreads
COMPONENT libopenthreads-dev
)
#commented out# INCLUDE(ModuleInstall OPTIONAL)

View File

@ -38,13 +38,14 @@ LINK_DIRECTORIES(
INSTALL(
TARGETS OpenThreads
ARCHIVE DESTINATION lib${LIB_POSTFIX}
LIBRARY DESTINATION lib${LIB_POSTFIX}
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib${LIB_POSTFIX} COMPONENT libopenthreads
LIBRARY DESTINATION lib${LIB_POSTFIX} COMPONENT libopenthreads
RUNTIME DESTINATION bin COMPONENT libopenthreads
)
INSTALL(
FILES ${OpenThreads_PUBLIC_HEADERS}
DESTINATION include/OpenThreads
COMPONENT libopenthreads-dev
)
#commented out# INCLUDE(ModuleInstall OPTIONAL)

View File

@ -41,13 +41,14 @@ ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
INSTALL(
TARGETS OpenThreads
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib COMPONENT libopenthreads-dev
LIBRARY DESTINATION lib COMPONENT libopenthreads
RUNTIME DESTINATION bin COMPONENT libopenthreads
)
INSTALL(
FILES ${OpenThreads_PUBLIC_HEADERS}
DESTINATION include/OpenThreads
COMPONENT libopenthreads-dev
)
#commented out# INCLUDE(ModuleInstall OPTIONAL)

View File

@ -23,4 +23,4 @@ INCLUDE_DIRECTORIES(${INVENTOR_INCLUDE_DIR})
SET(TARGET_LIBRARIES_VARS INVENTOR_LIBRARY)
SETUP_PLUGIN(iv)
SETUP_PLUGIN(iv iv)

View File

@ -59,4 +59,4 @@ ENDIF(COLLADA_USE_STATIC)
SET(TARGET_ADDED_LIBRARIES osgSim )
#### end var setup ###
SETUP_PLUGIN(dae)
SETUP_PLUGIN(dae dae)

View File

@ -13,4 +13,4 @@ SET(TARGET_LIBRARIES_VARS GDAL_LIBRARY )
SET(TARGET_ADDED_LIBRARIES osgTerrain )
#### end var setup ###
SETUP_PLUGIN(gdal)
SETUP_PLUGIN(gdal gdal)

View File

@ -62,5 +62,5 @@ ENDIF(WIN32 OR APPLE)
SET(TARGET_ADDED_LIBRARIES osgWidget osgViewer)
#### end var setup ###
SETUP_PLUGIN(gecko)
SETUP_PLUGIN(gecko gecko)

View File

@ -7,4 +7,4 @@ SET(TARGET_EXTERNAL_LIBRARIES ${CAIRO_LIBRARIES} ${POPPLER_LIBRARIES} )
SET(TARGET_ADDED_LIBRARIES osgWidget osgVolume)
#### end var setup ###
SETUP_PLUGIN(pdf)
SETUP_PLUGIN(pdf pdf)

View File

@ -8,4 +8,4 @@ LINK_LIBRARIES(${RSVG_LIBRARIES} ${CAIRO_LIBRARIES})
SET(TARGET_SRC ReaderWriterSVG.cpp )
#### end var setup ###
SETUP_PLUGIN(svg)
SETUP_PLUGIN(svg svg)

View File

@ -7,4 +7,4 @@ SET(TARGET_EXTERNAL_LIBRARIES ${LIBVNCCLIENT_LIBRARY} ${ZLIB_LIBRARY} ${JPEG_LIB
SET(TARGET_ADDED_LIBRARIES osgWidget )
#### end var setup ###
SETUP_PLUGIN(vnc)
SETUP_PLUGIN(vnc vnc)

View File

@ -22,4 +22,4 @@ SET(TARGET_H
)
#### end var setup ###
SETUP_PLUGIN(vrml)
SETUP_PLUGIN(vrml vrml)

View File

@ -160,5 +160,6 @@ FOREACH( INCLUDEFILE ${LIB_PUBLIC_HEADERS} )
INSTALL(
FILES ${INCLUDEFILE}
DESTINATION ${INSTALL_INCDIR}/${LIB_NAME}/${REL_INCLUDE_PATH}
COMPONENT libopenscenegraph-core-dev
)
ENDFOREACH( INCLUDEFILE)