1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-15 20:03:15 +02:00

Merge pull request #1081 from kambala-decapitator/macos-bundle-ID

[macOS] improve Info.plist
This commit is contained in:
Andrii Danylchenko
2022-10-23 10:39:05 +03:00
committed by GitHub
5 changed files with 32 additions and 20 deletions

View File

@@ -603,9 +603,12 @@ elseif(APPLE_MACOS AND NOT ENABLE_MONOLITHIC_INSTALL)
include(GetGitRevisionDescription) include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1) get_git_head_revision(GIT_REFSPEC GIT_SHA1)
string(TIMESTAMP CURRENT_YEAR "%Y")
set(MACOSX_BUNDLE_NAME "${CMAKE_PROJECT_NAME}") set(MACOSX_BUNDLE_NAME "${CMAKE_PROJECT_NAME}")
set(MACOSX_BUNDLE_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_BUNDLE_VERSION ${GIT_SHA1})
set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${APP_SHORT_VERSION}) set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${APP_SHORT_VERSION})
if(ENABLE_LAUNCHER) if(ENABLE_LAUNCHER)

View File

@@ -142,7 +142,7 @@ function(vcmi_install_conan_deps install_dir)
endif() endif()
install(CODE " install(CODE "
execute_process(COMMAND 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\") file(REMOVE \"${install_dir}/conan_imports_manifest.txt\")
") ")

View File

@@ -192,6 +192,7 @@ class VCMI(ConanFile):
def generate(self): def generate(self):
tc = CMakeToolchain(self) tc = CMakeToolchain(self)
tc.variables["USING_CONAN"] = True tc.variables["USING_CONAN"] = True
tc.variables["CONAN_INSTALL_FOLDER"] = self.install_folder
tc.generate() tc.generate()
deps = CMakeDeps(self) deps = CMakeDeps(self)

View File

@@ -4,19 +4,8 @@ if(APPLE_MACOS)
set(bundleDir "\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_DIR}") set(bundleDir "\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_DIR}")
set(bundleContentsDir "${bundleDir}/Contents") set(bundleContentsDir "${bundleDir}/Contents")
if(ENABLE_LAUNCHER) if(ENABLE_LAUNCHER OR ENABLE_EDITOR)
# cross-compiled Qt 5 builds macdeployqt for target platform instead of host if(USING_CONAN)
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()
# simulate macdeployqt behavior, main Qt libs are copied by conan # simulate macdeployqt behavior, main Qt libs are copied by conan
get_target_property(qmakePath Qt5::qmake IMPORTED_LOCATION) get_target_property(qmakePath Qt5::qmake IMPORTED_LOCATION)
execute_process(COMMAND execute_process(COMMAND
@@ -33,6 +22,19 @@ if(APPLE_MACOS)
\"[Paths]\nPlugins = PlugIns\" \"[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()
endif() endif()
@@ -40,15 +42,25 @@ if(APPLE_MACOS)
vcmi_install_conan_deps("${bundleContentsDir}") vcmi_install_conan_deps("${bundleContentsDir}")
# perform ad-hoc codesigning # 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(codesignCommand "codesign --verbose=4 --force --options=runtime --timestamp=none --sign -")
set(codesignCommandWithEntitlements "${codesignCommand} --entitlements \"${CMAKE_SOURCE_DIR}/osx/entitlements.plist\"") set(codesignCommandWithEntitlements "${codesignCommand} --entitlements \"${CMAKE_SOURCE_DIR}/osx/entitlements.plist\"")
install(CODE " install(CODE "
execute_process(COMMAND execute_process(COMMAND
${codesignCommand} \"${bundleContentsDir}/MacOS/vcmibuilder\" ${codesignCommand} \"${bundleContentsDir}/MacOS/vcmibuilder\"
) )
foreach(executable vcmiclient vcmiserver vcmilauncher) foreach(executable ${executablesToSign})
execute_process(COMMAND execute_process(COMMAND
${codesignCommandWithEntitlements} \"${bundleContentsDir}/MacOS/\${executable}\" ${codesignCommandWithEntitlements} --identifier eu.vcmi.\${executable} \"${bundleContentsDir}/MacOS/\${executable}\"
) )
endforeach() endforeach()
") ")

View File

@@ -6,14 +6,10 @@
<string>English</string> <string>English</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string> <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleGetInfoString</key>
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string>${MACOSX_BUNDLE_ICON_FILE}</string> <string>${MACOSX_BUNDLE_ICON_FILE}</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string> <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
<key>CFBundleLongVersionString</key>
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
<key>CFBundleName</key> <key>CFBundleName</key>
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string> <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>