CMakeLists.txt 4.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. if(ENABLE_LAUNCHER)
  5. find_program(TOOL_MACDEPLOYQT NAMES macdeployqt PATHS ${qt_base_dir}/bin)
  6. if(NOT TOOL_MACDEPLOYQT)
  7. message(FATAL_ERROR "Could not find macdeployqt")
  8. endif()
  9. install(CODE "
  10. execute_process(COMMAND ${TOOL_MACDEPLOYQT} \"\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_DIR}\" -verbose=2)
  11. ")
  12. endif()
  13. # Manually fix VCMI library links in AI libraries with install_name_tool
  14. install(CODE "
  15. set(BU_CHMOD_BUNDLE_ITEMS ON)
  16. include(BundleUtilities)
  17. fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_DIR}\" \"\" \"\")
  18. execute_process(COMMAND ${CMAKE_INSTALL_NAME_TOOL} -change \"libvcmi.dylib\" \"@executable_path/../Frameworks/libvcmi.dylib\" \"\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_BINARY_DIR}/AI/libBattleAI.dylib\")
  19. execute_process(COMMAND ${CMAKE_INSTALL_NAME_TOOL} -change \"libvcmi.dylib\" \"@executable_path/../Frameworks/libvcmi.dylib\" \"\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_BINARY_DIR}/AI/libEmptyAI.dylib\")
  20. execute_process(COMMAND ${CMAKE_INSTALL_NAME_TOOL} -change \"libvcmi.dylib\" \"@executable_path/../Frameworks/libvcmi.dylib\" \"\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_BINARY_DIR}/AI/libStupidAI.dylib\")
  21. execute_process(COMMAND ${CMAKE_INSTALL_NAME_TOOL} -change \"libvcmi.dylib\" \"@executable_path/../Frameworks/libvcmi.dylib\" \"\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_BINARY_DIR}/AI/libVCAI.dylib\")
  22. execute_process(COMMAND rm \"\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_BINARY_DIR}/libvcmi.dylib\")
  23. " COMPONENT Runtime)
  24. endif(APPLE)
  25. # This will likely only work for Vcpkg
  26. if(WIN32)
  27. if(ENABLE_LAUNCHER)
  28. # Temporary ugly fix for Qt deployment since windeployqt broken in Vcpkg
  29. #there are some weird issues with variables used in path not evaluated properly when trying to remove code duplication from below lines
  30. if(EXISTS ${CMAKE_BINARY_DIR}/../../vcpkg) #current path to vcpkg main folder on appveyor CI
  31. if(CMAKE_SIZEOF_VOID_P EQUAL 8) #64 bit build
  32. install(CODE "
  33. file(COPY ${CMAKE_BINARY_DIR}/../../vcpkg/installed/x64-windows/plugins/bearer DESTINATION \${CMAKE_INSTALL_PREFIX})
  34. file(COPY ${CMAKE_BINARY_DIR}/../../vcpkg/installed/x64-windows/plugins/iconengines DESTINATION \${CMAKE_INSTALL_PREFIX})
  35. file(COPY ${CMAKE_BINARY_DIR}/../../vcpkg/installed/x64-windows/plugins/imageformats DESTINATION \${CMAKE_INSTALL_PREFIX})
  36. file(COPY ${CMAKE_BINARY_DIR}/../../vcpkg/installed/x64-windows/plugins/platforminputcontexts DESTINATION \${CMAKE_INSTALL_PREFIX})
  37. file(COPY ${CMAKE_BINARY_DIR}/../../vcpkg/installed/x64-windows/plugins/platforms DESTINATION \${CMAKE_INSTALL_PREFIX})
  38. ")
  39. else()
  40. install(CODE "
  41. file(COPY ${CMAKE_BINARY_DIR}/../../vcpkg/installed/x86-windows/plugins/bearer DESTINATION \${CMAKE_INSTALL_PREFIX})
  42. file(COPY ${CMAKE_BINARY_DIR}/../../vcpkg/installed/x86-windows/plugins/iconengines DESTINATION \${CMAKE_INSTALL_PREFIX})
  43. file(COPY ${CMAKE_BINARY_DIR}/../../vcpkg/installed/x86-windows/plugins/imageformats DESTINATION \${CMAKE_INSTALL_PREFIX})
  44. file(COPY ${CMAKE_BINARY_DIR}/../../vcpkg/installed/x86-windows/plugins/platforminputcontexts DESTINATION \${CMAKE_INSTALL_PREFIX})
  45. file(COPY ${CMAKE_BINARY_DIR}/../../vcpkg/installed/x86-windows/plugins/platforms DESTINATION \${CMAKE_INSTALL_PREFIX})
  46. ")
  47. endif()
  48. else() #not appveyor build - lines below do not work properly
  49. install(CODE "
  50. execute_process(
  51. COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/bin/\${BUILD_TYPE}/bearer \${CMAKE_INSTALL_PREFIX}/bearer
  52. COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/bin/\${BUILD_TYPE}/iconengines \${CMAKE_INSTALL_PREFIX}/iconengines
  53. COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/bin/\${BUILD_TYPE}/imageformats \${CMAKE_INSTALL_PREFIX}/imageformats
  54. COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/bin/\${BUILD_TYPE}/platforminputcontexts \${CMAKE_INSTALL_PREFIX}/platforminputcontexts
  55. COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/bin/\${BUILD_TYPE}/platforms \${CMAKE_INSTALL_PREFIX}/platforms)
  56. ")
  57. endif()
  58. endif()
  59. #TODO: check if some equivalent of block below can be used for above block (easy qt dependencies copy)
  60. if(ENABLE_LUA)
  61. if(EXISTS ${LUA_INCLUDE_DIR}/../../bin/lua51.dll)
  62. install(CODE "
  63. file(COPY ${LUA_INCLUDE_DIR}/../../bin/lua51.dll DESTINATION \${CMAKE_INSTALL_PREFIX})
  64. ")
  65. endif()
  66. endif()
  67. #LuaJIT will not be copied automatically by not meeting criteria for this block of code
  68. install(CODE "
  69. if(\"\${BUILD_TYPE}\" STREQUAL \"Debug\")
  70. set(dirs \"${CMAKE_PREFIX_PATH}/debug/bin/\")
  71. else()
  72. set(dirs \"${CMAKE_PREFIX_PATH}/bin/\")
  73. endif()
  74. set(BU_CHMOD_BUNDLE_ITEMS ON)
  75. include(BundleUtilities)
  76. fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/VCMI_Client.exe\" \"\" \"\${dirs}\")
  77. " COMPONENT Runtime)
  78. endif(WIN32)