CMakeLists.txt 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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(APPLE_MACOS)
  4. set(bundleDir "\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_DIR}")
  5. set(bundleContentsDir "${bundleDir}/Contents")
  6. if(ENABLE_LAUNCHER OR ENABLE_EDITOR)
  7. if(USING_CONAN)
  8. # simulate macdeployqt behavior, main Qt libs are copied by conan
  9. execute_process(COMMAND
  10. "${qmakePath}" -query QT_INSTALL_PLUGINS
  11. OUTPUT_VARIABLE qtPluginsDir
  12. OUTPUT_STRIP_TRAILING_WHITESPACE
  13. )
  14. install(DIRECTORY
  15. ${qtPluginsDir}/
  16. DESTINATION ${APP_BUNDLE_DIR}/Contents/PlugIns
  17. )
  18. install(CODE "
  19. file(WRITE ${bundleContentsDir}/Resources/qt.conf
  20. \"[Paths]\nPlugins = PlugIns\"
  21. )
  22. ")
  23. else()
  24. # note: cross-compiled Qt 5 builds macdeployqt for target platform instead of host
  25. # deploy Qt dylibs with macdeployqt
  26. find_program(TOOL_MACDEPLOYQT NAMES macdeployqt PATHS "${qtBinDir}")
  27. if(TOOL_MACDEPLOYQT)
  28. install(CODE "
  29. execute_process(COMMAND
  30. \"${TOOL_MACDEPLOYQT}\" \"${bundleDir}\" -verbose=2
  31. )
  32. ")
  33. else()
  34. message(WARNING "macdeployqt not found, running cpack would result in broken package")
  35. endif()
  36. endif()
  37. endif()
  38. # deploy other dylibs with conan
  39. vcmi_install_conan_deps("${bundleContentsDir}")
  40. # perform ad-hoc codesigning
  41. # Intel Macs don't need it
  42. if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
  43. return()
  44. endif()
  45. set(executablesToSign vcmiserver)
  46. if(ENABLE_EDITOR)
  47. list(APPEND executablesToSign vcmieditor)
  48. endif()
  49. # main executable must be last
  50. list(APPEND executablesToSign vcmiclient)
  51. if(ENABLE_LAUNCHER)
  52. list(APPEND executablesToSign vcmilauncher)
  53. endif()
  54. set(codesignCommand "codesign --verbose=4 --force --options=runtime --timestamp=none --sign -")
  55. set(codesignCommandWithEntitlements "${codesignCommand} --entitlements \"${CMAKE_SOURCE_DIR}/osx/entitlements.plist\"")
  56. install(CODE "
  57. execute_process(COMMAND
  58. ${codesignCommand} \"${bundleContentsDir}/MacOS/vcmibuilder\"
  59. )
  60. foreach(executable ${executablesToSign})
  61. execute_process(COMMAND
  62. ${codesignCommandWithEntitlements} --identifier eu.vcmi.\${executable} \"${bundleContentsDir}/MacOS/\${executable}\"
  63. )
  64. endforeach()
  65. ")
  66. endif()