CMakeLists.txt 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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)
  7. # cross-compiled Qt 5 builds macdeployqt for target platform instead of host
  8. if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL CMAKE_SYSTEM_PROCESSOR)
  9. # deploy Qt dylibs with macdeployqt
  10. find_program(TOOL_MACDEPLOYQT NAMES macdeployqt PATHS ${qt_base_dir}/bin)
  11. if(NOT TOOL_MACDEPLOYQT)
  12. message(FATAL_ERROR "Could not find macdeployqt")
  13. endif()
  14. install(CODE "
  15. execute_process(COMMAND
  16. \"${TOOL_MACDEPLOYQT}\" \"${bundleDir}\" -verbose=2
  17. )
  18. ")
  19. else()
  20. # simulate macdeployqt behavior, main Qt libs are copied by conan
  21. get_target_property(qmakePath Qt5::qmake IMPORTED_LOCATION)
  22. execute_process(COMMAND
  23. "${qmakePath}" -query QT_INSTALL_PLUGINS
  24. OUTPUT_VARIABLE qtPluginsDir
  25. OUTPUT_STRIP_TRAILING_WHITESPACE
  26. )
  27. install(DIRECTORY
  28. ${qtPluginsDir}/
  29. DESTINATION ${APP_BUNDLE_DIR}/Contents/PlugIns
  30. )
  31. install(CODE "
  32. file(WRITE ${bundleContentsDir}/Resources/qt.conf
  33. \"[Paths]\nPlugins = PlugIns\"
  34. )
  35. ")
  36. endif()
  37. endif()
  38. # deploy other dylibs with conan
  39. vcmi_install_conan_deps("${bundleContentsDir}")
  40. # perform ad-hoc codesigning
  41. set(codesignCommand "codesign --verbose=4 --force --options=runtime --timestamp=none --sign -")
  42. set(codesignCommandWithEntitlements "${codesignCommand} --entitlements \"${CMAKE_SOURCE_DIR}/osx/entitlements.plist\"")
  43. install(CODE "
  44. execute_process(COMMAND
  45. ${codesignCommand} \"${bundleContentsDir}/MacOS/vcmibuilder\"
  46. )
  47. foreach(executable vcmiclient vcmiserver vcmilauncher)
  48. execute_process(COMMAND
  49. ${codesignCommandWithEntitlements} \"${bundleContentsDir}/MacOS/\${executable}\"
  50. )
  51. endforeach()
  52. ")
  53. endif()