CMakeLists.txt 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # We need to keep this code into separate directory so CMake will execute it after all other subdirectories install code
  2. # Otherwise we can't fix Mac bundle dependencies since binaries wouldn't be there when this code executed
  3. if(MACOS)
  4. set(bundleDir "\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_DIR}")
  5. set(bundleContentsDir "${bundleDir}/Contents")
  6. set(executablesDir "${bundleContentsDir}/MacOS")
  7. set(macdeployqtParams "\"${bundleDir}\"")
  8. if(ENABLE_EDITOR)
  9. string(APPEND macdeployqtParams " \"-executable=${executablesDir}/vcmieditor\"")
  10. endif()
  11. # note: cross-compiled Qt 5 builds macdeployqt for target platform instead of host
  12. vcmi_deploy_qt(macdeployqt "${macdeployqtParams}")
  13. # perform ad-hoc codesigning
  14. # Intel Macs don't need it
  15. if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
  16. return()
  17. endif()
  18. set(executablesToSign vcmiserver)
  19. if(ENABLE_EDITOR)
  20. list(APPEND executablesToSign vcmieditor)
  21. endif()
  22. # main executable must be last
  23. list(APPEND executablesToSign vcmiclient)
  24. if(ENABLE_LAUNCHER)
  25. list(APPEND executablesToSign vcmilauncher)
  26. endif()
  27. set(codesignCommand "codesign --verbose=4 --force --options=runtime --timestamp=none --sign -")
  28. set(codesignCommandWithEntitlements "${codesignCommand} --entitlements \"${CMAKE_SOURCE_DIR}/osx/entitlements.plist\"")
  29. install(CODE "
  30. execute_process(COMMAND
  31. ${codesignCommand} \"${executablesDir}/vcmibuilder\"
  32. )
  33. foreach(executable ${executablesToSign})
  34. execute_process(COMMAND
  35. ${codesignCommandWithEntitlements} --identifier eu.vcmi.\${executable} \"${executablesDir}/\${executable}\"
  36. )
  37. endforeach()
  38. ")
  39. endif()