mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-22 10:21:57 -05:00
Refactor macOS CMakeLists for .app bundle as default
This commit is contained in:
parent
2b37f4586a
commit
753ac907f8
1 changed files with 101 additions and 89 deletions
190
CMakeLists.txt
190
CMakeLists.txt
|
@ -61,8 +61,9 @@ option(DOWNLOAD_TITLE_SEQUENCES "Download title sequences during installation."
|
|||
option(DOWNLOAD_OBJECTS "Download objects during installation." ON)
|
||||
CMAKE_DEPENDENT_OPTION(DOWNLOAD_REPLAYS "Download replays during installation." ON
|
||||
"WITH_TESTS" OFF)
|
||||
option(MACOS_USE_DEPENDENCIES "Use OpenRCT2 dependencies instead of system libraries" ON)
|
||||
CMAKE_DEPENDENT_OPTION(MACOS_BUNDLE "Build macOS application bundle (OpenRCT2.app)" OFF
|
||||
CMAKE_DEPENDENT_OPTION(MACOS_USE_DEPENDENCIES "Use OpenRCT2 dependencies instead of system libraries" ON
|
||||
"APPLE" OFF)
|
||||
CMAKE_DEPENDENT_OPTION(MACOS_BUNDLE "Build macOS application bundle (OpenRCT2.app)" ON
|
||||
"MACOS_USE_DEPENDENCIES; NOT DISABLE_GUI" OFF)
|
||||
|
||||
# Options
|
||||
|
@ -104,9 +105,8 @@ if (APPIMAGE)
|
|||
set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")
|
||||
endif ()
|
||||
|
||||
if (APPLE AND MACOS_USE_DEPENDENCIES)
|
||||
if (MACOS_USE_DEPENDENCIES)
|
||||
# if we're building on macOS, then we need the dependencies
|
||||
# update dylibs
|
||||
include(cmake/download.cmake)
|
||||
|
||||
set(MACOS_DYLIBS_VERSION "28")
|
||||
|
@ -125,17 +125,21 @@ if (APPLE AND MACOS_USE_DEPENDENCIES)
|
|||
set(CMAKE_MACOSX_RPATH 1)
|
||||
list(APPEND CMAKE_PREFIX_PATH "${MACOS_DYLIBS_DIR}")
|
||||
|
||||
# the RPATH to be used when installing, but only if it's not a system directory
|
||||
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
|
||||
if("${isSystemDir}" STREQUAL "-1")
|
||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
endif("${isSystemDir}" STREQUAL "-1")
|
||||
# if we're making the OpenRCT2.app bundle, rpath will be handled by fixup_bundle
|
||||
# if we're building the CLI executable, we need to do it ourselves
|
||||
if (NOT MACOS_BUNDLE)
|
||||
# the RPATH to be used when installing, but only if it's not a system directory
|
||||
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
|
||||
if("${isSystemDir}" STREQUAL "-1")
|
||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
endif("${isSystemDir}" STREQUAL "-1")
|
||||
|
||||
# if the DESTDIR env var is defined, use it in the install RPATH
|
||||
if(DEFINED ENV{DESTDIR})
|
||||
get_filename_component(destdirRealPath "$ENV{DESTDIR}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
|
||||
set(CMAKE_INSTALL_RPATH "${destdirRealPath}${CMAKE_INSTALL_PREFIX}/lib")
|
||||
endif()
|
||||
# if the DESTDIR env var is defined, use it in the install RPATH
|
||||
if(DEFINED ENV{DESTDIR})
|
||||
get_filename_component(destdirRealPath "$ENV{DESTDIR}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
|
||||
set(CMAKE_INSTALL_RPATH "${destdirRealPath}${CMAKE_INSTALL_PREFIX}/lib")
|
||||
endif()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# LIST of supported flags, use SET_CHECK_CXX_FLAGS() to apply to target.
|
||||
|
@ -203,7 +207,7 @@ if (NOT DISABLE_DISCORD_RPC)
|
|||
add_definitions(-D__ENABLE_DISCORD__)
|
||||
include_directories(DISCORDRPC_PROCESS_INCLUDES)
|
||||
endif()
|
||||
elseif (APPLE AND MACOS_USE_DEPENDENCIES)
|
||||
elseif (MACOS_USE_DEPENDENCIES)
|
||||
find_package(discordrpc CONFIG REQUIRED)
|
||||
if(${DISCORDRPC_FOUND})
|
||||
add_definitions(-D__ENABLE_DISCORD__)
|
||||
|
@ -380,80 +384,88 @@ if (WITH_TESTS)
|
|||
include("${ROOT_DIR}/test/tests/CMakeLists.txt" NO_POLICY_SCOPE)
|
||||
endif ()
|
||||
|
||||
# Install
|
||||
# Don't recurse, grab all *.txt and *.md files
|
||||
file(GLOB DOC_FILES "${ROOT_DIR}/distribution/*.txt")
|
||||
list(APPEND DOC_FILES "${ROOT_DIR}/contributors.md"
|
||||
"${ROOT_DIR}/licence.txt"
|
||||
"${ROOT_DIR}/distribution/scripting.md"
|
||||
"${ROOT_DIR}/distribution/openrct2.d.ts")
|
||||
# macOS bundle "install" is handled in src/openrct2-ui/CMakeLists.txt
|
||||
# This is because the openrct2 target is modified (and that is where that target is defined)
|
||||
if (NOT MACOS_BUNDLE OR (MACOS_BUNDLE AND WITH_TESTS))
|
||||
# Install
|
||||
# Don't recurse, grab all *.txt and *.md files
|
||||
file(GLOB DOC_FILES "${ROOT_DIR}/distribution/*.txt")
|
||||
list(APPEND DOC_FILES "${ROOT_DIR}/contributors.md"
|
||||
"${ROOT_DIR}/licence.txt"
|
||||
"${ROOT_DIR}/distribution/scripting.md"
|
||||
"${ROOT_DIR}/distribution/openrct2.d.ts")
|
||||
|
||||
# CMake does not allow specifying a dependency chain which includes built-in
|
||||
# targets, like `install`, so we have to trick it and execute dependency ourselves.
|
||||
install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" --build \"${CMAKE_CURRENT_BINARY_DIR}\" --target g2)")
|
||||
if (DOWNLOAD_TITLE_SEQUENCES)
|
||||
# If openrct2.parkseq or data/sequence/ exists, assume all the title sequences are already present
|
||||
install(CODE
|
||||
"if (EXISTS \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/sequence/openrct2.parkseq\" OR EXISTS ${CMAKE_SOURCE_DIR}/data/sequence/)\n\
|
||||
message(\"Using cached title sequences\")\n\
|
||||
else () \n\
|
||||
file(DOWNLOAD ${TITLE_SEQUENCE_URL} \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/sequence/title-sequences.zip EXPECTED_HASH SHA1=${TITLE_SEQUENCE_SHA1} SHOW_PROGRESS)\n\
|
||||
execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/sequence/ \"${CMAKE_COMMAND}\" -E tar xf title-sequences.zip)\n\
|
||||
file(REMOVE \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/sequence/title-sequences.zip)\n\
|
||||
endif ()")
|
||||
endif ()
|
||||
if (DOWNLOAD_OBJECTS)
|
||||
# If rct2.wtrcyan.json or data/object/ exists, assume all the objects are already present
|
||||
install(CODE
|
||||
"if (EXISTS \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/object/rct2/water/rct2.wtrcyan.json\" OR EXISTS ${CMAKE_SOURCE_DIR}/data/object/)\n\
|
||||
message(\"Using cached objects\")\n\
|
||||
else () \n\
|
||||
file(DOWNLOAD ${OBJECTS_URL} \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/object/objects.zip EXPECTED_HASH SHA1=${OBJECTS_SHA1} SHOW_PROGRESS)\n\
|
||||
execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/object/ \"${CMAKE_COMMAND}\" -E tar xf objects.zip)\n\
|
||||
file(REMOVE \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/object/objects.zip)\n\
|
||||
endif ()")
|
||||
endif ()
|
||||
if (DOWNLOAD_REPLAYS)
|
||||
install(CODE
|
||||
"if (EXISTS \${CMAKE_CURRENT_BINARY_DIR}/testdata/replays/)\n\
|
||||
message(\"Using cached replays\")\n\
|
||||
else () \n\
|
||||
file(DOWNLOAD ${REPLAYS_URL} \${CMAKE_CURRENT_BINARY_DIR}/testdata/replays/replays.zip EXPECTED_HASH SHA1=${REPLAYS_SHA1} SHOW_PROGRESS)\n\
|
||||
execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \${CMAKE_CURRENT_BINARY_DIR}/testdata/replays/ \"${CMAKE_COMMAND}\" -E tar xf replays.zip)\n\
|
||||
file(REMOVE \${CMAKE_CURRENT_BINARY_DIR}/testdata/replays/replays.zip)\n\
|
||||
endif ()")
|
||||
endif ()
|
||||
install(TARGETS "libopenrct2" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||
if(NOT DISABLE_GUI AND NOT MACOS_BUNDLE)
|
||||
install(TARGETS "openrct2" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
endif()
|
||||
install(TARGETS "openrct2-cli" OPTIONAL RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/g2.dat" DESTINATION "${CMAKE_INSTALL_DATADIR}/openrct2")
|
||||
install(DIRECTORY "data/" DESTINATION "${CMAKE_INSTALL_DATADIR}/openrct2")
|
||||
install(FILES ${DOC_FILES} DESTINATION "${CMAKE_INSTALL_DOCDIR}")
|
||||
install(FILES "distribution/linux/openrct2.appdata.xml" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo")
|
||||
if (NOT DISABLE_GUI)
|
||||
install(FILES "resources/logo/icon_x16.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/16x16/apps" RENAME "openrct2.png")
|
||||
install(FILES "resources/logo/icon_x24.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/24x24/apps" RENAME "openrct2.png")
|
||||
install(FILES "resources/logo/icon_x32.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/32x32/apps" RENAME "openrct2.png")
|
||||
install(FILES "resources/logo/icon_x48.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48/apps" RENAME "openrct2.png")
|
||||
install(FILES "resources/logo/icon_x64.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/64x64/apps" RENAME "openrct2.png")
|
||||
install(FILES "resources/logo/icon_x96.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/96x96/apps" RENAME "openrct2.png")
|
||||
install(FILES "resources/logo/icon_x128.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128/apps" RENAME "openrct2.png")
|
||||
install(FILES "resources/logo/icon_x256.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/256x256/apps" RENAME "openrct2.png")
|
||||
install(FILES "resources/logo/icon_flag.svg" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps" RENAME "openrct2.svg")
|
||||
install(FILES "distribution/linux/openrct2.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
|
||||
install(FILES "distribution/linux/openrct2-savegame.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
|
||||
install(FILES "distribution/linux/openrct2-scenario.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
|
||||
install(FILES "distribution/linux/openrct2-uri.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
|
||||
endif()
|
||||
install(FILES "distribution/linux/openrct2-mimeinfo.xml" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/mime/packages/" RENAME "openrct2.xml")
|
||||
install(DIRECTORY "distribution/man/" DESTINATION "${CMAKE_INSTALL_MANDIR}/man6" FILES_MATCHING PATTERN "*.6")
|
||||
# CMake does not allow specifying a dependency chain which includes built-in
|
||||
# targets, like `install`, so we have to trick it and execute dependency ourselves.
|
||||
install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" --build \"${CMAKE_CURRENT_BINARY_DIR}\" --target g2)")
|
||||
if (DOWNLOAD_TITLE_SEQUENCES)
|
||||
# If openrct2.parkseq or data/sequence/ exists, assume all the title sequences are already present
|
||||
install(CODE
|
||||
"if (EXISTS \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/sequence/openrct2.parkseq\" OR EXISTS ${CMAKE_SOURCE_DIR}/data/sequence/)\n\
|
||||
message(\"Using cached title sequences\")\n\
|
||||
else () \n\
|
||||
file(DOWNLOAD ${TITLE_SEQUENCE_URL} \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/sequence/title-sequences.zip EXPECTED_HASH SHA1=${TITLE_SEQUENCE_SHA1} SHOW_PROGRESS)\n\
|
||||
execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/sequence/ \"${CMAKE_COMMAND}\" -E tar xf title-sequences.zip)\n\
|
||||
file(REMOVE \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/sequence/title-sequences.zip)\n\
|
||||
endif ()")
|
||||
endif ()
|
||||
if (DOWNLOAD_OBJECTS)
|
||||
# If rct2.wtrcyan.json or data/object/ exists, assume all the objects are already present
|
||||
install(CODE
|
||||
"if (EXISTS \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/object/rct2/water/rct2.wtrcyan.json\" OR EXISTS ${CMAKE_SOURCE_DIR}/data/object/)\n\
|
||||
message(\"Using cached objects\")\n\
|
||||
else () \n\
|
||||
file(DOWNLOAD ${OBJECTS_URL} \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/object/objects.zip EXPECTED_HASH SHA1=${OBJECTS_SHA1} SHOW_PROGRESS)\n\
|
||||
execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/object/ \"${CMAKE_COMMAND}\" -E tar xf objects.zip)\n\
|
||||
file(REMOVE \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/object/objects.zip)\n\
|
||||
endif ()")
|
||||
endif ()
|
||||
if (DOWNLOAD_REPLAYS)
|
||||
install(CODE
|
||||
"if (EXISTS \${CMAKE_CURRENT_BINARY_DIR}/testdata/replays/)\n\
|
||||
message(\"Using cached replays\")\n\
|
||||
else () \n\
|
||||
file(DOWNLOAD ${REPLAYS_URL} \${CMAKE_CURRENT_BINARY_DIR}/testdata/replays/replays.zip EXPECTED_HASH SHA1=${REPLAYS_SHA1} SHOW_PROGRESS)\n\
|
||||
execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \${CMAKE_CURRENT_BINARY_DIR}/testdata/replays/ \"${CMAKE_COMMAND}\" -E tar xf replays.zip)\n\
|
||||
file(REMOVE \${CMAKE_CURRENT_BINARY_DIR}/testdata/replays/replays.zip)\n\
|
||||
endif ()")
|
||||
endif ()
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/g2.dat" DESTINATION "${CMAKE_INSTALL_DATADIR}/openrct2")
|
||||
install(DIRECTORY "data/" DESTINATION "${CMAKE_INSTALL_DATADIR}/openrct2")
|
||||
|
||||
if (APPLE AND MACOS_USE_DEPENDENCIES)
|
||||
# Note: dependencies may have the same names as system installed libraries
|
||||
# (via homebrew). A local CMAKE_INSTALL_PREFIX is recommended to avoid issues
|
||||
file(GLOB DYLIB_FILES "${MACOS_DYLIBS_DIR}/lib/*.dylib")
|
||||
install(FILES ${DYLIB_FILES} DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||
# even when building WITH_TESTS, none of the below install steps are required for OpenRCT2.app
|
||||
if (NOT MACOS_BUNDLE)
|
||||
install(TARGETS "libopenrct2" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||
if(NOT DISABLE_GUI)
|
||||
install(TARGETS "openrct2" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
endif()
|
||||
install(TARGETS "openrct2-cli" OPTIONAL RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
install(FILES ${DOC_FILES} DESTINATION "${CMAKE_INSTALL_DOCDIR}")
|
||||
install(FILES "distribution/linux/openrct2.appdata.xml" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo")
|
||||
if (NOT DISABLE_GUI)
|
||||
install(FILES "resources/logo/icon_x16.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/16x16/apps" RENAME "openrct2.png")
|
||||
install(FILES "resources/logo/icon_x24.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/24x24/apps" RENAME "openrct2.png")
|
||||
install(FILES "resources/logo/icon_x32.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/32x32/apps" RENAME "openrct2.png")
|
||||
install(FILES "resources/logo/icon_x48.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48/apps" RENAME "openrct2.png")
|
||||
install(FILES "resources/logo/icon_x64.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/64x64/apps" RENAME "openrct2.png")
|
||||
install(FILES "resources/logo/icon_x96.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/96x96/apps" RENAME "openrct2.png")
|
||||
install(FILES "resources/logo/icon_x128.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128/apps" RENAME "openrct2.png")
|
||||
install(FILES "resources/logo/icon_x256.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/256x256/apps" RENAME "openrct2.png")
|
||||
install(FILES "resources/logo/icon_flag.svg" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps" RENAME "openrct2.svg")
|
||||
install(FILES "distribution/linux/openrct2.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
|
||||
install(FILES "distribution/linux/openrct2-savegame.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
|
||||
install(FILES "distribution/linux/openrct2-scenario.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
|
||||
install(FILES "distribution/linux/openrct2-uri.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
|
||||
endif()
|
||||
install(FILES "distribution/linux/openrct2-mimeinfo.xml" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/mime/packages/" RENAME "openrct2.xml")
|
||||
install(DIRECTORY "distribution/man/" DESTINATION "${CMAKE_INSTALL_MANDIR}/man6" FILES_MATCHING PATTERN "*.6")
|
||||
|
||||
if (MACOS_USE_DEPENDENCIES)
|
||||
# Note: dependencies may have the same names as system installed libraries
|
||||
# (via homebrew). A local CMAKE_INSTALL_PREFIX is recommended to avoid issues
|
||||
file(GLOB DYLIB_FILES "${MACOS_DYLIBS_DIR}/lib/*.dylib")
|
||||
install(FILES ${DYLIB_FILES} DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
|
Loading…
Reference in a new issue