1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2024-12-27 06:14:09 +00:00
OpenMW/cmake/SignMacApplications.cmake
Andrew Dunn 71f6f95020 Make Mac Plugins osgPlugins symlink relative
Was an absolute path.
2022-09-21 07:44:56 +10:00

21 lines
1.2 KiB
CMake

# This script re-signs OpenMW.app and OpenMW-CS.app after CPack packages them. This is necessary because CPack modifies
# the library references used by OpenMW to App relative paths, invalidating the code signature.
# Obviously, we only need to run this on Apple targets.
if (APPLE)
set(OPENMW_APP "OpenMW")
set(OPENMW_CS_APP "OpenMW-CS")
set(APPLICATIONS "${OPENMW_APP}" "${OPENMW_CS_APP}")
foreach(app_name IN LISTS APPLICATIONS)
set(FULL_APP_PATH "${CPACK_TEMPORARY_INSTALL_DIRECTORY}/ALL_IN_ONE/${app_name}.app")
message(STATUS "Re-signing ${app_name}.app")
# Apple's codesign utility does not like directories with periods (.) in their names, so we'll remove it and
# create a symlink using the original name, which codesign is fine with.
file(GLOB OSG_PLUGINS_DIR "${FULL_APP_PATH}/Contents/PlugIns/osgPlugins*")
file(RENAME "${OSG_PLUGINS_DIR}" "${FULL_APP_PATH}/Contents/PlugIns/osgPlugins")
execute_process(COMMAND "ln" "-s" "osgPlugins" "${OSG_PLUGINS_DIR}"
WORKING_DIRECTORY "${FULL_APP_PATH}/Contents/PlugIns/")
execute_process(COMMAND "codesign" "--force" "--deep" "-s" "-" "${FULL_APP_PATH}")
endforeach(app_name)
endif (APPLE)