From c9198311a1029be683a591e2cf1ae3513b4fd878 Mon Sep 17 00:00:00 2001 From: Andrey Filipenkov Date: Sat, 22 Oct 2022 16:52:27 +0300 Subject: [PATCH 1/7] [macOS] set bundle identifier to Info.plist --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3fd47aba1..711a08343 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -606,6 +606,7 @@ elseif(APPLE_MACOS AND NOT ENABLE_MONOLITHIC_INSTALL) set(MACOSX_BUNDLE_NAME "${CMAKE_PROJECT_NAME}") set(MACOSX_BUNDLE_BUNDLE_NAME "${CMAKE_PROJECT_NAME}") + set(MACOSX_BUNDLE_GUI_IDENTIFIER "eu.vcmi.vcmi") set(MACOSX_BUNDLE_BUNDLE_VERSION ${GIT_SHA1}) set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${APP_SHORT_VERSION}) if(ENABLE_LAUNCHER) From 002e09fa2dcde35a94feef4cb8579bf62b1fa96e Mon Sep 17 00:00:00 2001 From: Andrey Filipenkov Date: Sat, 22 Oct 2022 16:52:47 +0300 Subject: [PATCH 2/7] [macOS] set copyright to Info.plist --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 711a08343..af7427528 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -603,9 +603,11 @@ elseif(APPLE_MACOS AND NOT ENABLE_MONOLITHIC_INSTALL) include(GetGitRevisionDescription) get_git_head_revision(GIT_REFSPEC GIT_SHA1) + string(TIMESTAMP CURRENT_YEAR "%Y") set(MACOSX_BUNDLE_NAME "${CMAKE_PROJECT_NAME}") set(MACOSX_BUNDLE_BUNDLE_NAME "${CMAKE_PROJECT_NAME}") + set(MACOSX_BUNDLE_COPYRIGHT "Copyright © 2007-${CURRENT_YEAR} VCMI team") set(MACOSX_BUNDLE_GUI_IDENTIFIER "eu.vcmi.vcmi") set(MACOSX_BUNDLE_BUNDLE_VERSION ${GIT_SHA1}) set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${APP_SHORT_VERSION}) From 9865578faa61b8d45f74914d919de71503613f2c Mon Sep 17 00:00:00 2001 From: Andrey Filipenkov Date: Sat, 22 Oct 2022 16:53:08 +0300 Subject: [PATCH 3/7] [macOS] remove deprecated entries from Info.plist --- osx/Info.plist.in | 4 ---- 1 file changed, 4 deletions(-) diff --git a/osx/Info.plist.in b/osx/Info.plist.in index 23e9cd06a..b96130fa5 100644 --- a/osx/Info.plist.in +++ b/osx/Info.plist.in @@ -6,14 +6,10 @@ English CFBundleExecutable ${MACOSX_BUNDLE_EXECUTABLE_NAME} - CFBundleGetInfoString - ${MACOSX_BUNDLE_INFO_STRING} CFBundleIconFile ${MACOSX_BUNDLE_ICON_FILE} CFBundleIdentifier ${MACOSX_BUNDLE_GUI_IDENTIFIER} - CFBundleLongVersionString - ${MACOSX_BUNDLE_LONG_VERSION_STRING} CFBundleName ${MACOSX_BUNDLE_BUNDLE_NAME} CFBundlePackageType From 8e8323a3d5f6e98748823b9f4e74bd40d840725f Mon Sep 17 00:00:00 2001 From: Andrey Filipenkov Date: Sat, 22 Oct 2022 16:57:41 +0300 Subject: [PATCH 4/7] [macOS] build properly ordered list of executables that needs to be signed --- osx/CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/osx/CMakeLists.txt b/osx/CMakeLists.txt index cc5d83ea1..ba81cd0ab 100644 --- a/osx/CMakeLists.txt +++ b/osx/CMakeLists.txt @@ -40,13 +40,23 @@ if(APPLE_MACOS) vcmi_install_conan_deps("${bundleContentsDir}") # perform ad-hoc codesigning + set(executablesToSign vcmiserver) + if(ENABLE_EDITOR) + list(APPEND executablesToSign vcmieditor) + endif() + # main executable must be last + list(APPEND executablesToSign vcmiclient) + if(ENABLE_LAUNCHER) + list(APPEND executablesToSign vcmilauncher) + endif() + set(codesignCommand "codesign --verbose=4 --force --options=runtime --timestamp=none --sign -") set(codesignCommandWithEntitlements "${codesignCommand} --entitlements \"${CMAKE_SOURCE_DIR}/osx/entitlements.plist\"") install(CODE " execute_process(COMMAND ${codesignCommand} \"${bundleContentsDir}/MacOS/vcmibuilder\" ) - foreach(executable vcmiclient vcmiserver vcmilauncher) + foreach(executable ${executablesToSign}) execute_process(COMMAND ${codesignCommandWithEntitlements} \"${bundleContentsDir}/MacOS/\${executable}\" ) From 35a6a24204c54c7b26cbbbb652a2453378a50479 Mon Sep 17 00:00:00 2001 From: Andrey Filipenkov Date: Sat, 22 Oct 2022 16:58:12 +0300 Subject: [PATCH 5/7] [macOS] sign executables with bundle identifier --- osx/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osx/CMakeLists.txt b/osx/CMakeLists.txt index ba81cd0ab..b9adb221b 100644 --- a/osx/CMakeLists.txt +++ b/osx/CMakeLists.txt @@ -58,7 +58,7 @@ if(APPLE_MACOS) ) foreach(executable ${executablesToSign}) execute_process(COMMAND - ${codesignCommandWithEntitlements} \"${bundleContentsDir}/MacOS/\${executable}\" + ${codesignCommandWithEntitlements} --identifier eu.vcmi.\${executable} \"${bundleContentsDir}/MacOS/\${executable}\" ) endforeach() ") From d1ab611b4fd73308da6644e668971cceac9f53fe Mon Sep 17 00:00:00 2001 From: Andrey Filipenkov Date: Sat, 22 Oct 2022 16:59:26 +0300 Subject: [PATCH 6/7] [macOS] don't use macdeployqt together with Conan --- osx/CMakeLists.txt | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/osx/CMakeLists.txt b/osx/CMakeLists.txt index b9adb221b..5ce47c1c4 100644 --- a/osx/CMakeLists.txt +++ b/osx/CMakeLists.txt @@ -4,19 +4,8 @@ if(APPLE_MACOS) set(bundleDir "\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_DIR}") set(bundleContentsDir "${bundleDir}/Contents") - if(ENABLE_LAUNCHER) - # cross-compiled Qt 5 builds macdeployqt for target platform instead of host - if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL CMAKE_SYSTEM_PROCESSOR) - # deploy Qt dylibs with macdeployqt - find_program(TOOL_MACDEPLOYQT NAMES macdeployqt PATHS ${qt_base_dir}/bin) - endif() - if(TOOL_MACDEPLOYQT) - install(CODE " - execute_process(COMMAND - \"${TOOL_MACDEPLOYQT}\" \"${bundleDir}\" -verbose=2 - ) - ") - else() + if(ENABLE_LAUNCHER OR ENABLE_EDITOR) + if(USING_CONAN) # simulate macdeployqt behavior, main Qt libs are copied by conan get_target_property(qmakePath Qt5::qmake IMPORTED_LOCATION) execute_process(COMMAND @@ -33,6 +22,19 @@ if(APPLE_MACOS) \"[Paths]\nPlugins = PlugIns\" ) ") + else() + # note: cross-compiled Qt 5 builds macdeployqt for target platform instead of host + # deploy Qt dylibs with macdeployqt + find_program(TOOL_MACDEPLOYQT NAMES macdeployqt PATHS ${qt_base_dir}/bin) + if(TOOL_MACDEPLOYQT) + install(CODE " + execute_process(COMMAND + \"${TOOL_MACDEPLOYQT}\" \"${bundleDir}\" -verbose=2 + ) + ") + else() + message(WARNING "macdeployqt not found, running cpack would result in broken package") + endif() endif() endif() From e0e075df775c10b7238a8c86105504badde55334 Mon Sep 17 00:00:00 2001 From: Andrey Filipenkov Date: Sat, 22 Oct 2022 16:54:07 +0300 Subject: [PATCH 7/7] [Conan] save install folder to CMake variable --- cmake_modules/VCMIUtils.cmake | 2 +- conanfile.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake_modules/VCMIUtils.cmake b/cmake_modules/VCMIUtils.cmake index 50ace693d..55516601f 100644 --- a/cmake_modules/VCMIUtils.cmake +++ b/cmake_modules/VCMIUtils.cmake @@ -142,7 +142,7 @@ function(vcmi_install_conan_deps install_dir) endif() install(CODE " execute_process(COMMAND - conan imports \"${CMAKE_SOURCE_DIR}\" --install-folder \"${CMAKE_SOURCE_DIR}/conan-generated\" --import-folder \"${install_dir}\" + conan imports \"${CMAKE_SOURCE_DIR}\" --install-folder \"${CONAN_INSTALL_FOLDER}\" --import-folder \"${install_dir}\" ) file(REMOVE \"${install_dir}/conan_imports_manifest.txt\") ") diff --git a/conanfile.py b/conanfile.py index c733ab611..fd6108234 100644 --- a/conanfile.py +++ b/conanfile.py @@ -192,6 +192,7 @@ class VCMI(ConanFile): def generate(self): tc = CMakeToolchain(self) tc.variables["USING_CONAN"] = True + tc.variables["CONAN_INSTALL_FOLDER"] = self.install_folder tc.generate() deps = CMakeDeps(self)