qt_build_submodule.cmake 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. function(qt_build_submodule SOURCE_PATH)
  2. # This fixes issues on machines with default codepages that are not ASCII compatible, such as some CJK encodings
  3. set(ENV{_CL_} "/utf-8")
  4. vcpkg_find_acquire_program(PYTHON2)
  5. get_filename_component(PYTHON2_EXE_PATH ${PYTHON2} DIRECTORY)
  6. vcpkg_add_to_path("${PYTHON2_EXE_PATH}")
  7. vcpkg_configure_qmake(SOURCE_PATH ${SOURCE_PATH} ${ARGV})
  8. vcpkg_build_qmake(SKIP_MAKEFILES)
  9. #Fix the installation location within the makefiles
  10. qt_fix_makefile_install("${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/")
  11. qt_fix_makefile_install("${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/")
  12. #Install the module files
  13. vcpkg_build_qmake(TARGETS install SKIP_MAKEFILES BUILD_LOGNAME install)
  14. qt_fix_cmake(${CURRENT_PACKAGES_DIR} ${PORT})
  15. #Replace with VCPKG variables if PR #7733 is merged
  16. unset(BUILDTYPES)
  17. if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
  18. set(_buildname "DEBUG")
  19. list(APPEND BUILDTYPES ${_buildname})
  20. set(_short_name_${_buildname} "dbg")
  21. set(_path_suffix_${_buildname} "/debug")
  22. endif()
  23. if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
  24. set(_buildname "RELEASE")
  25. list(APPEND BUILDTYPES ${_buildname})
  26. set(_short_name_${_buildname} "rel")
  27. set(_path_suffix_${_buildname} "")
  28. endif()
  29. unset(_buildname)
  30. foreach(_buildname ${BUILDTYPES})
  31. set(CURRENT_BUILD_PACKAGE_DIR "${CURRENT_PACKAGES_DIR}${_path_suffix_${_buildname}}")
  32. #Fix PRL files
  33. file(GLOB_RECURSE PRL_FILES "${CURRENT_BUILD_PACKAGE_DIR}/lib/*.prl" "${CURRENT_PACKAGES_DIR}/tools/qt5${_path_suffix_${_buildname}}/lib/*.prl"
  34. "${CURRENT_PACKAGES_DIR}/tools/qt5${_path_suffix_${_buildname}}/mkspecs/*.pri")
  35. qt_fix_prl("${CURRENT_BUILD_PACKAGE_DIR}" "${PRL_FILES}")
  36. # This makes it impossible to use the build tools in any meaningful way. qt5 assumes they are all in one folder!
  37. # So does the Qt VS Plugin which even assumes all of the in a bin folder
  38. #Move tools to the correct directory
  39. #if(EXISTS ${CURRENT_BUILD_PACKAGE_DIR}/tools/qt5)
  40. # file(RENAME ${CURRENT_BUILD_PACKAGE_DIR}/tools/qt5 ${CURRENT_PACKAGES_DIR}/tools/${PORT})
  41. #endif()
  42. # Move executables in bin to tools
  43. # This is ok since those are not build tools.
  44. file(GLOB PACKAGE_EXE ${CURRENT_BUILD_PACKAGE_DIR}/bin/*.exe)
  45. if(PACKAGE_EXE)
  46. file(INSTALL ${PACKAGE_EXE} DESTINATION "${CURRENT_BUILD_PACKAGE_DIR}/tools/${PORT}")
  47. file(REMOVE ${PACKAGE_EXE})
  48. foreach(_exe ${PACKAGE_EXE})
  49. string(REPLACE ".exe" ".pdb" _prb_file ${_exe})
  50. if(EXISTS ${_prb_file})
  51. file(INSTALL ${_prb_file} DESTINATION "${CURRENT_BUILD_PACKAGE_DIR}/tools/${PORT}")
  52. file(REMOVE ${_prb_file})
  53. endif()
  54. endforeach()
  55. endif()
  56. #cleanup empty folders
  57. file(GLOB PACKAGE_LIBS "${CURRENT_BUILD_PACKAGE_DIR}/lib/*")
  58. if(NOT PACKAGE_LIBS)
  59. file(REMOVE_RECURSE "${CURRENT_BUILD_PACKAGE_DIR}/lib")
  60. endif()
  61. file(GLOB PACKAGE_BINS "${CURRENT_BUILD_PACKAGE_DIR}/bin/*")
  62. if(NOT PACKAGE_BINS)
  63. file(REMOVE_RECURSE "${CURRENT_BUILD_PACKAGE_DIR}/bin")
  64. endif()
  65. endforeach()
  66. if(EXISTS "${CURRENT_PACKAGES_DIR}/tools/qt5/bin")
  67. file(COPY "${CURRENT_PACKAGES_DIR}/tools/qt5/bin" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
  68. set(CURRENT_INSTALLED_DIR_BACKUP "${CURRENT_INSTALLED_DIR}")
  69. set(CURRENT_INSTALLED_DIR "./../../.." ) # Making the qt.conf relative and not absolute
  70. configure_file(${CURRENT_INSTALLED_DIR_BACKUP}/tools/qt5/qt_release.conf ${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin/qt.conf) # This makes the tools at least useable for release
  71. set(CURRENT_INSTALLED_DIR "${CURRENT_INSTALLED_DIR_BACKUP}")
  72. vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin")
  73. if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
  74. file(GLOB_RECURSE DLL_DEPS_AVAIL "${CURRENT_INSTALLED_DIR}/tools/qt5/bin/*.dll")
  75. string(REPLACE "${CURRENT_INSTALLED_DIR}/tools/qt5/bin/" "" DLL_DEPS_AVAIL "${DLL_DEPS_AVAIL}")
  76. file(GLOB_RECURSE DLL_DEPS_NEEDED "${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin/*.dll")
  77. string(REPLACE "${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin/" "" DLL_DEPS_NEEDED "${DLL_DEPS_NEEDED}")
  78. if(DLL_DEPS_AVAIL AND DLL_DEPS_NEEDED)
  79. list(REMOVE_ITEM DLL_DEPS_NEEDED ${DLL_DEPS_AVAIL})
  80. endif()
  81. foreach(dll_dep ${DLL_DEPS_NEEDED})
  82. string(REGEX REPLACE "[^/]+$" "" dll_subpath "${dll_dep}")
  83. file(COPY "${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin/${dll_dep}" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/qt5/bin/${dll_subpath}")
  84. endforeach()
  85. endif()
  86. endif()
  87. #This should be removed if somehow possible
  88. if(EXISTS "${CURRENT_PACKAGES_DIR}/tools/qt5/debug/bin")
  89. set(CURRENT_INSTALLED_DIR_BACKUP "${CURRENT_INSTALLED_DIR}")
  90. set(CURRENT_INSTALLED_DIR "./../../../.." ) # Making the qt.conf relative and not absolute
  91. configure_file(${CURRENT_INSTALLED_DIR_BACKUP}/tools/qt5/qt_debug.conf ${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug/bin/qt.conf) # This makes the tools at least useable for release
  92. set(CURRENT_INSTALLED_DIR "${CURRENT_INSTALLED_DIR_BACKUP}")
  93. vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug/bin")
  94. if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
  95. file(GLOB_RECURSE DLL_DEPS_AVAIL "${CURRENT_INSTALLED_DIR}/tools/qt5/debug/bin/*.dll")
  96. string(REPLACE "${CURRENT_INSTALLED_DIR}/tools/qt5/debug/bin/" "" DLL_DEPS_AVAIL "${DLL_DEPS_AVAIL}")
  97. file(GLOB_RECURSE DLL_DEPS_NEEDED "${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug/bin/*.dll")
  98. string(REPLACE "${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin/" "" DLL_DEPS_NEEDED "${DLL_DEPS_NEEDED}")
  99. if(DLL_DEPS_AVAIL AND DLL_DEPS_NEEDED)
  100. list(REMOVE_ITEM DLL_DEPS_NEEDED ${DLL_DEPS_AVAIL})
  101. endif()
  102. foreach(dll_dep ${DLL_DEPS_NEEDED})
  103. string(REGEX REPLACE "[^/]+$" "" dll_subpath "${dll_dep}")
  104. file(COPY "${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug/bin/${dll_dep}" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/qt5/debug/bin/${dll_subpath}")
  105. endforeach()
  106. endif()
  107. endif()
  108. endfunction()