2017-08-12 20:58:09 +02:00
|
|
|
# We need to keep this code into separate directory so CMake will execute it after all other subdirectories install code
|
|
|
|
# Otherwise we can't fix Mac bundle dependencies since binaries wouldn't be there when this code executed
|
2021-03-01 10:38:21 +02:00
|
|
|
if(APPLE_MACOS)
|
2022-08-30 16:29:00 +02:00
|
|
|
set(bundleDir "\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_DIR}")
|
|
|
|
set(bundleContentsDir "${bundleDir}/Contents")
|
|
|
|
|
2017-08-12 20:58:09 +02:00
|
|
|
if(ENABLE_LAUNCHER)
|
2022-08-30 16:29:00 +02:00
|
|
|
# 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)
|
2022-10-18 19:37:08 +02:00
|
|
|
endif()
|
|
|
|
if(TOOL_MACDEPLOYQT)
|
2022-08-30 16:29:00 +02:00
|
|
|
install(CODE "
|
|
|
|
execute_process(COMMAND
|
|
|
|
\"${TOOL_MACDEPLOYQT}\" \"${bundleDir}\" -verbose=2
|
|
|
|
)
|
|
|
|
")
|
|
|
|
else()
|
|
|
|
# simulate macdeployqt behavior, main Qt libs are copied by conan
|
|
|
|
get_target_property(qmakePath Qt5::qmake IMPORTED_LOCATION)
|
|
|
|
execute_process(COMMAND
|
|
|
|
"${qmakePath}" -query QT_INSTALL_PLUGINS
|
|
|
|
OUTPUT_VARIABLE qtPluginsDir
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
install(DIRECTORY
|
|
|
|
${qtPluginsDir}/
|
|
|
|
DESTINATION ${APP_BUNDLE_DIR}/Contents/PlugIns
|
|
|
|
)
|
|
|
|
install(CODE "
|
|
|
|
file(WRITE ${bundleContentsDir}/Resources/qt.conf
|
|
|
|
\"[Paths]\nPlugins = PlugIns\"
|
|
|
|
)
|
|
|
|
")
|
2017-08-12 20:58:09 +02:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2022-08-30 16:29:00 +02:00
|
|
|
# deploy other dylibs with conan
|
2022-10-13 12:04:32 +02:00
|
|
|
vcmi_install_conan_deps("${bundleContentsDir}")
|
2022-09-13 14:27:44 +02:00
|
|
|
|
|
|
|
# perform ad-hoc codesigning
|
2022-10-22 15:57:41 +02:00
|
|
|
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()
|
|
|
|
|
2022-09-13 14:27:44 +02:00
|
|
|
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\"
|
|
|
|
)
|
2022-10-22 15:57:41 +02:00
|
|
|
foreach(executable ${executablesToSign})
|
2022-09-13 14:27:44 +02:00
|
|
|
execute_process(COMMAND
|
2022-10-22 15:58:12 +02:00
|
|
|
${codesignCommandWithEntitlements} --identifier eu.vcmi.\${executable} \"${bundleContentsDir}/MacOS/\${executable}\"
|
2022-09-13 14:27:44 +02:00
|
|
|
)
|
|
|
|
endforeach()
|
|
|
|
")
|
2021-03-01 10:38:21 +02:00
|
|
|
endif()
|