From 9e898bca06f87cb4a9fa3e70144ca378885e40bd Mon Sep 17 00:00:00 2001 From: Steveice10 <1269164+Steveice10@users.noreply.github.com> Date: Fri, 1 Sep 2023 15:18:47 -0700 Subject: [PATCH] build: Fix Qt installer build script. (#6938) --- CMakeModules/BuildInstaller.cmake | 4 ++- CMakeModules/DownloadExternals.cmake | 43 ++++++++++++++++------------ dist/installer/CMakeLists.txt | 2 ++ 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/CMakeModules/BuildInstaller.cmake b/CMakeModules/BuildInstaller.cmake index 07700bc51..ce9cadc65 100644 --- a/CMakeModules/BuildInstaller.cmake +++ b/CMakeModules/BuildInstaller.cmake @@ -1,4 +1,5 @@ # To use this as a script, make sure you pass in the variables BASE_DIR, SRC_DIR, BUILD_DIR, and TARGET_FILE +cmake_minimum_required(VERSION 3.15) if(WIN32) set(PLATFORM "windows") @@ -12,7 +13,8 @@ endif() list(APPEND CMAKE_MODULE_PATH "${BASE_DIR}/CMakeModules") include(DownloadExternals) -download_qt(tools_ifw QT_PREFIX) +download_qt(tools_ifw) +get_external_prefix(qt QT_PREFIX) file(GLOB_RECURSE INSTALLER_BASE "${QT_PREFIX}/**/installerbase*") file(GLOB_RECURSE BINARY_CREATOR "${QT_PREFIX}/**/binarycreator*") diff --git a/CMakeModules/DownloadExternals.cmake b/CMakeModules/DownloadExternals.cmake index 7ec6c7570..410a8801f 100644 --- a/CMakeModules/DownloadExternals.cmake +++ b/CMakeModules/DownloadExternals.cmake @@ -1,31 +1,38 @@ -# This function downloads Qt using aqt. +# This function downloads Qt using aqt. The path of the downloaded content will be added to the CMAKE_PREFIX_PATH. # Params: # target: Qt dependency to install. Specify a version number to download Qt, or "tools_(name)" for a specific build tool. -# prefix_var: Name of a variable which will be set with the path to the extracted contents. function(download_qt target) + if (target MATCHES "tools_.*") + set(DOWNLOAD_QT_TOOL ON) + else() + set(DOWNLOAD_QT_TOOL OFF) + endif() + # Determine installation parameters for OS, architecture, and compiler if (WIN32) set(host "windows") set(type "desktop") - 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") + 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}") else() - message(FATAL_ERROR "Unsupported bundled Qt architecture. Enable USE_SYSTEM_QT and provide your own.") + message(FATAL_ERROR "Unsupported bundled Qt toolchain. Enable USE_SYSTEM_QT and provide your own.") endif() - set(arch "win64_${arch_path}") - else() - message(FATAL_ERROR "Unsupported bundled Qt toolchain. Enable USE_SYSTEM_QT and provide your own.") endif() elseif (APPLE) set(host "mac") - if (IOS) + if (IOS AND NOT DOWNLOAD_QT_TOOL) set(type "ios") set(arch "ios") set(arch_path "ios") @@ -45,8 +52,8 @@ function(download_qt target) get_external_prefix(qt base_path) file(MAKE_DIRECTORY "${base_path}") - if (target MATCHES "tools_.*") - set(prefix "${base_path}") + if (DOWNLOAD_QT_TOOL) + set(prefix "${base_path}/Tools") set(install_args install-tool --outputdir ${base_path} ${host} desktop ${target}) else() set(prefix "${base_path}/${target}/${arch_path}") @@ -63,7 +70,7 @@ function(download_qt target) if (WIN32) set(aqt_path "${base_path}/aqt.exe") file(DOWNLOAD - https://github.com/miurahr/aqtinstall/releases/download/v3.1.4/aqt.exe + https://github.com/miurahr/aqtinstall/releases/download/v3.1.7/aqt.exe ${aqt_path} SHOW_PROGRESS) execute_process(COMMAND ${aqt_path} ${install_args} WORKING_DIRECTORY ${base_path}) diff --git a/dist/installer/CMakeLists.txt b/dist/installer/CMakeLists.txt index 05f39edb0..2217f8348 100644 --- a/dist/installer/CMakeLists.txt +++ b/dist/installer/CMakeLists.txt @@ -13,6 +13,8 @@ set(BUILD_DIR "${CMAKE_BINARY_DIR}/installer") set(DIST_DIR "${BUILD_DIR}/dist") set(TARGET_FILE "${DIST_DIR}/citra-setup-${PLATFORM}") +file(MAKE_DIRECTORY "${BUILD_DIR}" "${DIST_DIR}") + # Adds a custom target that will run the BuildInstaller.cmake file # CMake can't just run a cmake function as a custom command, so this is a way around it. # Calls the cmake command and runs a cmake file in "scripting" mode passing in variables with -D