2017-09-09 18:24:13 +01:00
|
|
|
|
2023-11-11 19:52:11 +00:00
|
|
|
set(CURRENT_MODULE_DIR ${CMAKE_CURRENT_LIST_DIR})
|
|
|
|
|
2023-09-01 23:18:47 +01:00
|
|
|
# This function downloads Qt using aqt. The path of the downloaded content will be added to the CMAKE_PREFIX_PATH.
|
2023-04-28 21:02:53 +01:00
|
|
|
# Params:
|
|
|
|
# target: Qt dependency to install. Specify a version number to download Qt, or "tools_(name)" for a specific build tool.
|
2023-06-27 01:42:00 +01:00
|
|
|
function(download_qt target)
|
2023-09-01 23:18:47 +01:00
|
|
|
if (target MATCHES "tools_.*")
|
|
|
|
set(DOWNLOAD_QT_TOOL ON)
|
|
|
|
else()
|
|
|
|
set(DOWNLOAD_QT_TOOL OFF)
|
|
|
|
endif()
|
|
|
|
|
2023-04-28 21:02:53 +01:00
|
|
|
# Determine installation parameters for OS, architecture, and compiler
|
|
|
|
if (WIN32)
|
|
|
|
set(host "windows")
|
2023-06-08 04:40:53 +01:00
|
|
|
set(type "desktop")
|
2023-09-01 23:18:47 +01:00
|
|
|
if (NOT DOWNLOAD_QT_TOOL)
|
|
|
|
if (MINGW)
|
|
|
|
set(arch "win64_mingw")
|
|
|
|
set(arch_path "mingw_64")
|
|
|
|
elseif (MSVC)
|
|
|
|
if ("arm64" IN_LIST ARCHITECTURE)
|
|
|
|
set(arch_path "msvc2019_arm64")
|
|
|
|
elseif ("x86_64" IN_LIST ARCHITECTURE)
|
|
|
|
set(arch_path "msvc2019_64")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Unsupported bundled Qt architecture. Enable USE_SYSTEM_QT and provide your own.")
|
|
|
|
endif()
|
|
|
|
set(arch "win64_${arch_path}")
|
2023-04-28 21:02:53 +01:00
|
|
|
else()
|
2023-09-01 23:18:47 +01:00
|
|
|
message(FATAL_ERROR "Unsupported bundled Qt toolchain. Enable USE_SYSTEM_QT and provide your own.")
|
2023-04-28 21:02:53 +01:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
elseif (APPLE)
|
|
|
|
set(host "mac")
|
2023-09-01 23:18:47 +01:00
|
|
|
if (IOS AND NOT DOWNLOAD_QT_TOOL)
|
2023-06-08 04:40:53 +01:00
|
|
|
set(type "ios")
|
|
|
|
set(arch "ios")
|
|
|
|
set(arch_path "ios")
|
|
|
|
set(host_arch_path "macos")
|
|
|
|
else()
|
|
|
|
set(type "desktop")
|
|
|
|
set(arch "clang_64")
|
|
|
|
set(arch_path "macos")
|
|
|
|
endif()
|
2023-04-28 21:02:53 +01:00
|
|
|
else()
|
|
|
|
set(host "linux")
|
2023-06-08 04:40:53 +01:00
|
|
|
set(type "desktop")
|
2023-04-28 21:02:53 +01:00
|
|
|
set(arch "gcc_64")
|
|
|
|
set(arch_path "linux")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
get_external_prefix(qt base_path)
|
2023-05-31 23:42:13 +01:00
|
|
|
file(MAKE_DIRECTORY "${base_path}")
|
|
|
|
|
2023-11-11 19:52:11 +00:00
|
|
|
set(install_args -c "${CURRENT_MODULE_DIR}/aqt_config.ini")
|
2023-09-01 23:18:47 +01:00
|
|
|
if (DOWNLOAD_QT_TOOL)
|
|
|
|
set(prefix "${base_path}/Tools")
|
2023-11-11 19:52:11 +00:00
|
|
|
set(install_args ${install_args} install-tool --outputdir ${base_path} ${host} desktop ${target})
|
2023-04-28 21:02:53 +01:00
|
|
|
else()
|
|
|
|
set(prefix "${base_path}/${target}/${arch_path}")
|
2023-06-08 04:40:53 +01:00
|
|
|
if (host_arch_path)
|
|
|
|
set(host_flag "--autodesktop")
|
|
|
|
set(host_prefix "${base_path}/${target}/${host_arch_path}")
|
|
|
|
endif()
|
2023-11-11 19:52:11 +00:00
|
|
|
set(install_args ${install_args} install-qt --outputdir ${base_path} ${host} ${type} ${target} ${arch} ${host_flag}
|
2023-08-10 22:32:51 +01:00
|
|
|
-m qtmultimedia --archives qttranslations qttools qtsvg qtbase)
|
2023-04-28 21:02:53 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (NOT EXISTS "${prefix}")
|
|
|
|
message(STATUS "Downloading binaries for Qt...")
|
2023-11-06 20:26:50 +00:00
|
|
|
set(AQT_PREBUILD_BASE_URL "https://github.com/miurahr/aqtinstall/releases/download/v3.1.9")
|
2023-04-28 21:02:53 +01:00
|
|
|
if (WIN32)
|
2023-05-31 23:42:13 +01:00
|
|
|
set(aqt_path "${base_path}/aqt.exe")
|
2023-04-28 21:02:53 +01:00
|
|
|
file(DOWNLOAD
|
2023-11-06 20:26:50 +00:00
|
|
|
${AQT_PREBUILD_BASE_URL}/aqt.exe
|
2023-04-28 21:02:53 +01:00
|
|
|
${aqt_path} SHOW_PROGRESS)
|
2023-05-31 23:42:13 +01:00
|
|
|
execute_process(COMMAND ${aqt_path} ${install_args}
|
|
|
|
WORKING_DIRECTORY ${base_path})
|
2023-11-06 20:26:50 +00:00
|
|
|
elseif (APPLE)
|
|
|
|
set(aqt_path "${base_path}/aqt-macos")
|
|
|
|
file(DOWNLOAD
|
|
|
|
${AQT_PREBUILD_BASE_URL}/aqt-macos
|
|
|
|
${aqt_path} SHOW_PROGRESS)
|
|
|
|
execute_process(COMMAND chmod +x ${aqt_path})
|
|
|
|
execute_process(COMMAND ${aqt_path} ${install_args}
|
|
|
|
WORKING_DIRECTORY ${base_path})
|
2023-04-28 21:02:53 +01:00
|
|
|
else()
|
|
|
|
# aqt does not offer binary releases for other platforms, so download and run from pip.
|
2023-05-31 23:42:13 +01:00
|
|
|
set(aqt_install_path "${base_path}/aqt")
|
|
|
|
file(MAKE_DIRECTORY "${aqt_install_path}")
|
|
|
|
|
|
|
|
execute_process(COMMAND python3 -m pip install --target=${aqt_install_path} aqtinstall
|
|
|
|
WORKING_DIRECTORY ${base_path})
|
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${aqt_install_path} python3 -m aqt ${install_args}
|
|
|
|
WORKING_DIRECTORY ${base_path})
|
2023-04-28 21:02:53 +01:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
message(STATUS "Using downloaded Qt binaries at ${prefix}")
|
2023-06-08 04:40:53 +01:00
|
|
|
|
|
|
|
# Add the Qt prefix path so CMake can locate it.
|
|
|
|
list(APPEND CMAKE_PREFIX_PATH "${prefix}")
|
|
|
|
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} PARENT_SCOPE)
|
|
|
|
|
|
|
|
if (DEFINED host_prefix)
|
|
|
|
message(STATUS "Using downloaded host Qt binaries at ${host_prefix}")
|
|
|
|
set(QT_HOST_PATH "${host_prefix}" CACHE STRING "")
|
|
|
|
endif()
|
2023-04-28 21:02:53 +01:00
|
|
|
endfunction()
|
|
|
|
|
2023-06-05 15:29:05 +01:00
|
|
|
function(download_moltenvk)
|
|
|
|
if (IOS)
|
|
|
|
set(MOLTENVK_PLATFORM "iOS")
|
|
|
|
else()
|
|
|
|
set(MOLTENVK_PLATFORM "macOS")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(MOLTENVK_DIR "${CMAKE_BINARY_DIR}/externals/MoltenVK")
|
|
|
|
set(MOLTENVK_TAR "${CMAKE_BINARY_DIR}/externals/MoltenVK.tar")
|
|
|
|
if (NOT EXISTS ${MOLTENVK_DIR})
|
|
|
|
if (NOT EXISTS ${MOLTENVK_TAR})
|
2024-01-12 17:16:04 +00:00
|
|
|
file(DOWNLOAD https://github.com/KhronosGroup/MoltenVK/releases/download/v1.2.7-rc2/MoltenVK-all.tar
|
2023-06-05 15:29:05 +01:00
|
|
|
${MOLTENVK_TAR} SHOW_PROGRESS)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf "${MOLTENVK_TAR}"
|
|
|
|
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/externals")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Add the MoltenVK library path to the prefix so find_library can locate it.
|
|
|
|
list(APPEND CMAKE_PREFIX_PATH "${MOLTENVK_DIR}/MoltenVK/dylib/${MOLTENVK_PLATFORM}")
|
|
|
|
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
2023-04-28 21:02:53 +01:00
|
|
|
function(get_external_prefix lib_name prefix_var)
|
|
|
|
set(${prefix_var} "${CMAKE_BINARY_DIR}/externals/${lib_name}" PARENT_SCOPE)
|
|
|
|
endfunction()
|