From 2fa9b091dc928152553d9a92f80c9ffeda5cd2f6 Mon Sep 17 00:00:00 2001 From: beaglejoe Date: Mon, 30 Mar 2020 05:21:39 +0000 Subject: [PATCH] Ticket #1021 wip git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@6874 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 8711e4e3683d9dd5f3ff93a8766e2e34a67842fe Former-commit-id: 85966ce188f4633263d543c737ffc3bdbbe483a3 --- CMakeLists.txt | 7 ++- cmake/fixbundle.cmake.in | 65 ++++++++++++++++++++++++ cmake/macros.cmake | 2 + packaging/CMakeLists.txt | 79 +++++++++++++++++++++++++++++ src/main/CMakeLists.txt | 84 +------------------------------ src/tools/accc/CMakeLists.txt | 12 ----- src/tools/menuview/CMakeLists.txt | 13 ----- src/tools/nfs2ac/CMakeLists.txt | 12 ----- src/tools/nfsperf/CMakeLists.txt | 12 ----- src/tools/trackgen/CMakeLists.txt | 12 ----- 10 files changed, 152 insertions(+), 146 deletions(-) create mode 100644 cmake/fixbundle.cmake.in create mode 100644 packaging/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 739a7a199..2bc69a7fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,6 +134,7 @@ SD_SETUP_SETTINGS_VERSION() SET_PROPERTY(GLOBAL PROPERTY SD_MODULE_LIST "") SET_PROPERTY(GLOBAL PROPERTY SD_ROBOT_LIST "") SET_PROPERTY(GLOBAL PROPERTY SD_OSG_PLUGIN_LIST "") +SET_PROPERTY(GLOBAL PROPERTY SD_EXE_LIST "") # Sub-dirs to build ... ADD_SUBDIRECTORY(src) @@ -147,6 +148,9 @@ SD_UPDATE_SETTINGS_VERSION() # Usefull for using an installation of SD as a robot development framework without building it. INSTALL_SD_CMAKE() +# Must be the last ADD_SUBDIRECTORY for FIXUP_BUNDLE to work +ADD_SUBDIRECTORY(packaging) + # Generate a 'make clobber'-like clobber.sh/.bat script in case of an in-source build. IF("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}") SD_GENERATE_CLOBBER_SCRIPT() @@ -169,5 +173,4 @@ IF(OPTION_PACKAGING) ELSE(OPTION_PACKAGING) # Configure CPack. INCLUDE(cmake/packagemaker.cmake) -ENDIF(OPTION_PACKAGING) - +ENDIF(OPTION_PACKAGING) \ No newline at end of file diff --git a/cmake/fixbundle.cmake.in b/cmake/fixbundle.cmake.in new file mode 100644 index 000000000..9e80c9871 --- /dev/null +++ b/cmake/fixbundle.cmake.in @@ -0,0 +1,65 @@ +#============================================================================== +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +#============================================================================== + +INCLUDE(BundleUtilities) +SET(BU_CHMOD_BUNDLE_ITEMS ON) + +SET(bundle "@CMAKE_BINARY_DIR@/@CMAKE_INSTALL_PREFIX@/@SD_BINDIR@/@PROJECT_NAME@@CMAKE_EXECUTABLE_SUFFIX@") + + +SET(loadables @SD_MODULE_LIST_ITEMS@) +SET(robots @SD_ROBOT_LIST_ITEMS@) +SET(osg-plugins @SD_OSG_PLUGIN_LIST_ITEMS@) +SET(plugins ${osg-plugins}) +SET(_prefix_path @CMAKE_PREFIX_PATH@) + +foreach(_MODULE ${loadables}) + #message(STATUS "${_MODULE}") + LIST(APPEND plugins "@CMAKE_BINARY_DIR@/@CMAKE_INSTALL_PREFIX@/${_MODULE}") +endforeach() + +message(STATUS "Robots...") +foreach(_ROBOT ${robots}) + #message(STATUS "${_ROBOT}") + LIST(APPEND plugins "@CMAKE_BINARY_DIR@/@CMAKE_INSTALL_PREFIX@/${_ROBOT}") +endforeach() + +#message(STATUS "plugins...") +#foreach(_MODULE ${plugins}) +# message(STATUS "plugins = ${_MODULE}") +#endforeach() + + +# TODO - APPLE specific ? +SET(search_dirs ) +IF(_prefix_path) + LIST(APPEND search_dirs "${_prefix_path}") +ENDIF(_prefix_path) +LIST(APPEND search_dirs "@CMAKE_BINARY_DIR@/@CMAKE_INSTALL_PREFIX@") +LIST(APPEND search_dirs "@CMAKE_INSTALL_PREFIX@/Frameworks") +LIST(APPEND search_dirs "@CMAKE_INSTALL_PREFIX@/MacOS") +LIST(APPEND search_dirs "@CMAKE_INSTALL_PREFIX@/lib64/games/speed-dreams-2/lib") +LIST(APPEND search_dirs "@CMAKE_INSTALL_PREFIX@/games/Plugins/osgPlugins-@OSG_PLUGIN_VERSION@") + + +FIXUP_BUNDLE("${bundle}" "${plugins}" "${search_dirs}") + +message(STATUS bundle = "${bundle}") +message(STATUS plugins = "${plugins}") +message(STATUS search_dirs = "${search_dirs}") +message(STATUS _prefix_path = "${_prefix_path}") + diff --git a/cmake/macros.cmake b/cmake/macros.cmake index b2dcd39c3..f6a455685 100644 --- a/cmake/macros.cmake +++ b/cmake/macros.cmake @@ -206,6 +206,8 @@ MACRO(SD_ADD_EXECUTABLE TARGET_NAME) ENDIF(MSVC) + SET_PROPERTY(GLOBAL APPEND PROPERTY SD_EXE_LIST "${SD_BINDIR}/${TARGET_NAME}${CMAKE_EXECUTABLE_SUFFIX}") + # Make the "settings_versions" target depend on this target, # in order settings_versions is built after them. ADD_DEPENDENCIES(settings_versions ${TARGET_NAME}) diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt new file mode 100644 index 000000000..fa302a8a1 --- /dev/null +++ b/packaging/CMakeLists.txt @@ -0,0 +1,79 @@ +#============================================================================== +# +# file : CMakeLists.txt +# copyright : (C) 2019 Joe Thompson +# email : beaglejoe@users.sourceforge.net +# web : www.speed-dreams.org +# version : $Id$ +# +#============================================================================== +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +#============================================================================== +INCLUDE(../cmake/macros.cmake) + +#============================================================================== +IF((APPLE) AND ("${CMAKE_INSTALL_PREFIX}" MATCHES "\\.app$")) + # TODO get these elsewhwere... + SET(OSG_PLUGIN_VERSION 3.6.4) + SET(OSG_PLUGIN_DIR /opt/local/lib/osgPlugins-${OSG_PLUGIN_VERSION}) + + IF(OPTION_OSGGRAPH) + FILE(GLOB osg_plugins "${OSG_PLUGIN_DIR}/*.so") + message("osg_plugins = ${osg_plugins}") + FOREACH(pi ${osg_plugins}) + INSTALL(FILES ${pi} DESTINATION ./games/PlugIns/osgPlugins-${OSG_PLUGIN_VERSION}) + GET_FILENAME_COMPONENT(fname ${pi} NAME) + SET_PROPERTY(GLOBAL APPEND PROPERTY SD_OSG_PLUGIN_LIST "${CMAKE_INSTALL_PREFIX}/games/PlugIns/osgPlugins-${OSG_PLUGIN_VERSION}/${fname}") + ENDFOREACH() + ENDIF(OPTION_OSGGRAPH) + +ENDIF() +#============================================================================== + +IF((APPLE) AND ("${CMAKE_INSTALL_PREFIX}" MATCHES "\\.app$")) + GET_PROPERTY(SD_MODULE_LIST_ITEMS GLOBAL PROPERTY SD_MODULE_LIST) + GET_PROPERTY(SD_ROBOT_LIST_ITEMS GLOBAL PROPERTY SD_ROBOT_LIST) + GET_PROPERTY(SD_OSG_PLUGIN_LIST_ITEMS GLOBAL PROPERTY SD_OSG_PLUGIN_LIST) + #GET_PROPERTY(SD_EXE_LIST_ITEMS GLOBAL PROPERTY SD_EXE_LIST) + + SET (_bundle "${CMAKE_INSTALL_PREFIX}/${SD_BINDIR}/${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}") + + SET(_loadables ) + + foreach(_MODULE ${SD_MODULE_LIST_ITEMS}) + LIST(APPEND _loadables "${CMAKE_INSTALL_PREFIX}/${_MODULE}") + endforeach() + + foreach(_ROBOT ${SD_ROBOT_LIST_ITEMS}) + LIST(APPEND _loadables "${CMAKE_INSTALL_PREFIX}/${_MODULE}") + endforeach() + + #================ + # TODO figure out if this is needed... + IF(NOT OPTION_OFFICIAL_ONLY) + LIST(APPEND _loadables "\${CMAKE_INSTALL_PREFIX}/lib64/games/${_TARGET_NAME}/lib/libephemeris.dylib") + ENDIF(NOT OPTION_OFFICIAL_ONLY) + LIST(APPEND _loadables "${CMAKE_INSTALL_PREFIX}/lib64/games/${_TARGET_NAME}/lib/liblearning.dylib") + #================ + + + CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/fixbundle.cmake.in + ${CMAKE_BINARY_DIR}/fixbundle.cmake @ONLY) + + INSTALL(SCRIPT "${CMAKE_BINARY_DIR}/fixbundle.cmake") + + #ADD_CUSTOM_TARGET(${_UNINST_TGT_NAME} "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake" ) +ENDIF() diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt index 606b9b122..5b42681a4 100644 --- a/src/main/CMakeLists.txt +++ b/src/main/CMakeLists.txt @@ -48,91 +48,9 @@ ENDIF(UNIX) SD_INSTALL_FILES(BIN TARGETS ${_TARGET_NAME}) -GET_PROPERTY(SD_MODULE_LIST_ITEMS GLOBAL PROPERTY SD_MODULE_LIST) -GET_PROPERTY(SD_ROBOT_LIST_ITEMS GLOBAL PROPERTY SD_ROBOT_LIST) -GET_PROPERTY(SD_OSG_PLUGIN_LIST_ITEMS GLOBAL PROPERTY SD_OSG_PLUGIN_LIST) - - - IF((APPLE) AND ("${CMAKE_INSTALL_PREFIX}" MATCHES "\\.app$")) - SET(OSG_PLUGIN_VERSION 3.6.4) -SET(OSG_PLUGIN_DIR /opt/local/lib/osgPlugins-${OSG_PLUGIN_VERSION}) - message("OSG_PLUGIN_DIR = ${OSG_PLUGIN_DIR}") INSTALL(FILES ../../packaging/OSX/Info.plist DESTINATION ./Contents) -INSTALL(FILES ../../packaging/OSX/sd-icon-mac-256.icns DESTINATION ./Contents/Resources) - SET(APPS "\${CMAKE_INSTALL_PREFIX}/games/${_TARGET_NAME}") - SET(DIRS ) - SET(PlugIns ) -#SET(DIRS ${DIRS} "${OSG_PLUGIN_DIR}") - - # need to switch on CMake version 3.8.0 ?? - # use MacOS before 3.8.0 - # use Frameworks from 3.8.0 onward - SET(DIRS ${DIRS} "\${CMAKE_INSTALL_PREFIX}/MacOS") - SET(DIRS ${DIRS} "\${CMAKE_INSTALL_PREFIX}/Frameworks") - - - SET(DIRS ${DIRS} "\${CMAKE_INSTALL_PREFIX}/lib64/games/${_TARGET_NAME}/lib") - SET(DIRS ${DIRS} /opt/local/lib) - - # TODO need to fixup some of these.. - # These should be pulled into "\${CMAKE_INSTALL_PREFIX}/MacOS" as needed by others -IF(NOT OPTION_OFFICIAL_ONLY) - LIST(APPEND PlugIns "\${CMAKE_INSTALL_PREFIX}/lib64/games/${_TARGET_NAME}/lib/libephemeris.dylib") -ENDIF(NOT OPTION_OFFICIAL_ONLY) - -LIST(APPEND PlugIns "\${CMAKE_INSTALL_PREFIX}/lib64/games/${_TARGET_NAME}/lib/liblearning.dylib") -#LIST(APPEND PlugIns "\${CMAKE_INSTALL_PREFIX}/lib64/games/${_TARGET_NAME}/lib/libnetworking.dylib") -#LIST(APPEND PlugIns "\${CMAKE_INSTALL_PREFIX}/lib64/games/${_TARGET_NAME}/lib/libportability.dylib") -#LIST(APPEND PlugIns "\${CMAKE_INSTALL_PREFIX}/lib64/games/${_TARGET_NAME}/lib/librobottools.dylib") -#LIST(APPEND PlugIns "\${CMAKE_INSTALL_PREFIX}/lib64/games/${_TARGET_NAME}/lib/libtgf.dylib") -#LIST(APPEND PlugIns "\${CMAKE_INSTALL_PREFIX}/lib64/games/${_TARGET_NAME}/lib/libtgfclient.dylib") -#LIST(APPEND PlugIns "\${CMAKE_INSTALL_PREFIX}/lib64/games/${_TARGET_NAME}/lib/libtgfdata.dylib") -ENDIF((APPLE) AND ("${CMAKE_INSTALL_PREFIX}" MATCHES "\\.app$")) - -foreach(_MODULE ${SD_MODULE_LIST_ITEMS}) - #message(STATUS "\${CMAKE_INSTALL_PREFIX}/${_MODULE}") - LIST(APPEND PlugIns "\${CMAKE_INSTALL_PREFIX}/${_MODULE}") -endforeach() - -foreach(_ROBOT ${SD_ROBOT_LIST_ITEMS}) - #message(STATUS "\${CMAKE_INSTALL_PREFIX}/${_ROBOT}") - LIST(APPEND PlugIns "\${CMAKE_INSTALL_PREFIX}/${_ROBOT}") -endforeach() - -IF((APPLE) AND ("${CMAKE_INSTALL_PREFIX}" MATCHES "\\.app$")) - - IF(OPTION_OSGGRAPH) -#SET(OSG_PLUGIN_DIR /opt/local/lib/osgPlugins-${OSG_PLUGIN_VERSION}) -#INSTALL(DIRECTORY "${OSG_PLUGIN_DIR}" DESTINATION ./MacOS FILES_MATCHING PATTERN "*.so") - LIST(APPEND PlugIns "\${CMAKE_INSTALL_PREFIX}/lib64/games/${_TARGET_NAME}/modules/graphic/osggraph.so") - FILE(GLOB osg_plugins "${OSG_PLUGIN_DIR}/*.so") -message("osg_plugins = ${osg_plugins}") - FOREACH(pi ${osg_plugins}) -INSTALL(FILES ${pi} DESTINATION ./games/PlugIns/osgPlugins-${OSG_PLUGIN_VERSION}) - GET_FILENAME_COMPONENT(fname ${pi} NAME) - message("fname = ${fname}") - LIST(APPEND PlugIns "\${CMAKE_INSTALL_PREFIX}/games/PlugIns/osgPlugins-${OSG_PLUGIN_VERSION}/${fname}") - ENDFOREACH() - ENDIF(OPTION_OSGGRAPH) - - message("PlugIns = ${PlugIns}") -message("DIRS = ${DIRS}") - - -# These are installed by their respective CMakeLists.txt -# Executables -#LIST(APPEND PlugIns ${CMAKE_INSTALL_PREFIX}/games/sd2-accc) -#LIST(APPEND PlugIns ${CMAKE_INSTALL_PREFIX}/games/sd2-menuview) -#LIST(APPEND PlugIns ${CMAKE_INSTALL_PREFIX}/games/sd2-nfs2ac) -#LIST(APPEND PlugIns ${CMAKE_INSTALL_PREFIX}/games/sd2-nfsperf) -#LIST(APPEND PlugIns ${CMAKE_INSTALL_PREFIX}/games/sd2-sd2-trackgen) - - INSTALL(CODE " - INCLUDE(BundleUtilities) - SET(BU_CHMOD_BUNDLE_ITEMS ON) - FIXUP_BUNDLE(\"${APPS}\" \"${PlugIns}\" \"${DIRS}\")") - + INSTALL(FILES ../../packaging/OSX/sd-icon-mac-256.icns DESTINATION ./Contents/Resources) ENDIF() # Under Windows, install needed 3rd party DLLs close to Speed Dreams executable. diff --git a/src/tools/accc/CMakeLists.txt b/src/tools/accc/CMakeLists.txt index e5e7048bc..81aeb1639 100644 --- a/src/tools/accc/CMakeLists.txt +++ b/src/tools/accc/CMakeLists.txt @@ -19,15 +19,3 @@ IF(UNIX) ENDIF(UNIX) SD_INSTALL_FILES(BIN TARGETS ${_TARGET_NAME}) - -IF((APPLE) AND ("${CMAKE_INSTALL_PREFIX}" MATCHES "\\.app$")) - SET(APPS "\${CMAKE_INSTALL_PREFIX}/games/${_TARGET_NAME}") - SET(DIRS /opt/local) - SET(DIRS ${DIRS} "\${CMAKE_INSTALL_PREFIX}/lib64/games/${_TARGET_NAME}/lib") - SET(PlugIns) - - INSTALL(CODE " - INCLUDE(BundleUtilities) - SET(BU_CHMOD_BUNDLE_ITEMS ON) - FIXUP_BUNDLE(\"${APPS}\" \"${PlugIns}\" \"${DIRS}\")") -endif() \ No newline at end of file diff --git a/src/tools/menuview/CMakeLists.txt b/src/tools/menuview/CMakeLists.txt index f978d4a11..5d50d5592 100644 --- a/src/tools/menuview/CMakeLists.txt +++ b/src/tools/menuview/CMakeLists.txt @@ -58,16 +58,3 @@ IF(UNIX) ENDIF(UNIX) SD_INSTALL_FILES(BIN TARGETS ${_TARGET_NAME}) - -IF((APPLE) AND ("${CMAKE_INSTALL_PREFIX}" MATCHES "\\.app$")) - SET(APPS "\${CMAKE_INSTALL_PREFIX}/games/${_TARGET_NAME}") - SET(DIRS /opt/local) - SET(DIRS ${DIRS} "\${CMAKE_INSTALL_PREFIX}/lib64/games/${_TARGET_NAME}/lib") - SET(PlugIns) - - INSTALL(CODE " - INCLUDE(BundleUtilities) - SET(BU_CHMOD_BUNDLE_ITEMS ON) - FIXUP_BUNDLE(\"${APPS}\" \"${PlugIns}\" \"${DIRS}\")") -endif() - diff --git a/src/tools/nfs2ac/CMakeLists.txt b/src/tools/nfs2ac/CMakeLists.txt index a26967b85..1be8e5785 100644 --- a/src/tools/nfs2ac/CMakeLists.txt +++ b/src/tools/nfs2ac/CMakeLists.txt @@ -13,15 +13,3 @@ IF(UNIX) ENDIF(UNIX) SD_INSTALL_FILES(BIN TARGETS ${_TARGET_NAME}) - -IF((APPLE) AND ("${CMAKE_INSTALL_PREFIX}" MATCHES "\\.app$")) - set(APPS "\${CMAKE_INSTALL_PREFIX}/games/${_TARGET_NAME}") - set(DIRS /opt/local) - set(DIRS ${DIRS} "\${CMAKE_INSTALL_PREFIX}/lib64/games/${_TARGET_NAME}/lib") - set(PlugIns) - - INSTALL(CODE " - include(BundleUtilities) - fixup_bundle(\"${APPS}\" \"${PlugIns}\" \"${DIRS}\") - " COMPONENT Runtime) -endif() diff --git a/src/tools/nfsperf/CMakeLists.txt b/src/tools/nfsperf/CMakeLists.txt index 0a2a6b626..547d5dd1d 100644 --- a/src/tools/nfsperf/CMakeLists.txt +++ b/src/tools/nfsperf/CMakeLists.txt @@ -25,15 +25,3 @@ IF(UNIX) ENDIF(UNIX) SD_INSTALL_FILES(BIN TARGETS ${_TARGET_NAME}) - -IF((APPLE) AND ("${CMAKE_INSTALL_PREFIX}" MATCHES "\\.app$")) - SET(APPS "\${CMAKE_INSTALL_PREFIX}/games/${_TARGET_NAME}") - SET(DIRS /opt/local) - SET(DIRS ${DIRS} "\${CMAKE_INSTALL_PREFIX}/lib64/games/${_TARGET_NAME}/lib") - SET(PlugIns) - - INSTALL(CODE " - INCLUDE(BundleUtilities) - SET(BU_CHMOD_BUNDLE_ITEMS ON) - FIXUP_BUNDLE(\"${APPS}\" \"${PlugIns}\" \"${DIRS}\")") -endif() \ No newline at end of file diff --git a/src/tools/trackgen/CMakeLists.txt b/src/tools/trackgen/CMakeLists.txt index 914acd209..6a60f5e3e 100644 --- a/src/tools/trackgen/CMakeLists.txt +++ b/src/tools/trackgen/CMakeLists.txt @@ -63,15 +63,3 @@ IF(UNIX) ENDIF(UNIX) SD_INSTALL_FILES(BIN TARGETS ${_TARGET_NAME}) - -IF((APPLE) AND ("${CMAKE_INSTALL_PREFIX}" MATCHES "\\.app$")) - SET(APPS "\${CMAKE_INSTALL_PREFIX}/games/${_TARGET_NAME}") - SET(DIRS /opt/local) - SET(DIRS ${DIRS} "\${CMAKE_INSTALL_PREFIX}/lib64/games/${_TARGET_NAME}/lib") - SET(PlugIns) - - INSTALL(CODE " - INCLUDE(BundleUtilities) - SET(BU_CHMOD_BUNDLE_ITEMS ON) - FIXUP_BUNDLE(\"${APPS}\" \"${PlugIns}\" \"${DIRS}\")") -endif()