Skip to content

Commit

Permalink
build: Fix Qt installer build script. (#6938)
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveice10 authored Sep 1, 2023
1 parent cab0ad5 commit 9e898bc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
4 changes: 3 additions & 1 deletion CMakeModules/BuildInstaller.cmake
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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*")
Expand Down
43 changes: 25 additions & 18 deletions CMakeModules/DownloadExternals.cmake
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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}")
Expand All @@ -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})
Expand Down
2 changes: 2 additions & 0 deletions dist/installer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9e898bc

Please sign in to comment.