CMakeLists.txt 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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)
  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. install(CODE "
  40. execute_process(COMMAND
  41. conan imports \"${CMAKE_SOURCE_DIR}\" --install-folder \"${CMAKE_SOURCE_DIR}/conan-generated\" --import-folder \"${bundleContentsDir}\"
  42. )
  43. file(REMOVE \"${bundleContentsDir}/conan_imports_manifest.txt\")
  44. ")
  45. # perform ad-hoc codesigning
  46. set(codesignCommand "codesign --verbose=4 --force --options=runtime --timestamp=none --sign -")
  47. set(codesignCommandWithEntitlements "${codesignCommand} --entitlements \"${CMAKE_SOURCE_DIR}/osx/entitlements.plist\"")
  48. install(CODE "
  49. execute_process(COMMAND
  50. ${codesignCommand} \"${bundleContentsDir}/MacOS/vcmibuilder\"
  51. )
  52. foreach(executable vcmiclient vcmiserver vcmilauncher)
  53. execute_process(COMMAND
  54. ${codesignCommandWithEntitlements} \"${bundleContentsDir}/MacOS/\${executable}\"
  55. )
  56. endforeach()
  57. ")
  58. endif(APPLE)