diff options
Diffstat (limited to 'cmake/QtBuildInternalsExtra.cmake.in')
-rw-r--r-- | cmake/QtBuildInternalsExtra.cmake.in | 95 |
1 files changed, 44 insertions, 51 deletions
diff --git a/cmake/QtBuildInternalsExtra.cmake.in b/cmake/QtBuildInternalsExtra.cmake.in index 864e5badcc..8985f8178a 100644 --- a/cmake/QtBuildInternalsExtra.cmake.in +++ b/cmake/QtBuildInternalsExtra.cmake.in @@ -1,3 +1,6 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + # Propagate common variables via BuildInternals package. set(QT_BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@) option(BUILD_SHARED_LIBS "Build Qt statically or dynamically" @BUILD_SHARED_LIBS@) @@ -13,6 +16,24 @@ get_filename_component(QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX ${CMAKE_CURRENT_LIST_DIR}/../@qt_path_from_cmake_config_dir_to_prefix@ ABSOLUTE) +# Stores in out_var the new install/staging prefix for this build. +# +# new_prefix: the new prefix for this repository +# orig_prefix: the prefix that was used when qtbase was configured +# +# On Windows hosts: if the original prefix does not start with a drive letter, this function removes +# the drive letter from the new prefix. This is needed for installation with DESTDIR set. +function(qt_internal_new_prefix out_var new_prefix orig_prefix) + if(CMAKE_HOST_WIN32) + set(drive_letter_regexp "^[a-zA-Z]:") + if(new_prefix MATCHES "${drive_letter_regexp}" + AND NOT orig_prefix MATCHES "${drive_letter_regexp}") + string(SUBSTRING "${new_prefix}" 2 -1 new_prefix) + endif() + endif() + set(${out_var} "${new_prefix}" PARENT_SCOPE) +endfunction() + # If no explicit CMAKE_INSTALL_PREFIX is provided, force set the original Qt installation prefix, # so that further modules / repositories are installed into same original location. # This means by default when configuring qtsvg / qtdeclarative, they will be installed the regular @@ -25,32 +46,26 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND NOT QT_BUILD_INTERNALS_NO_FORCE_SET_INSTALL_PREFIX AND NOT QT_SUPERBUILD) set(qtbi_orig_prefix "@CMAKE_INSTALL_PREFIX@") - set(qtbi_new_prefix "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}") set(qtbi_orig_staging_prefix "@CMAKE_STAGING_PREFIX@") - if(CMAKE_HOST_WIN32) - # Make sure we use exactly the original prefix if it points to the same directory as the new - # one. This is needed for the case where the original prefix is passed without drive letter - # to support installing with DESTDIR set. - get_filename_component(qtbi_real_orig_prefix "${qtbi_orig_prefix}" REALPATH) - get_filename_component(qtbi_real_new_prefix "${qtbi_new_prefix}" REALPATH) - if(qtbi_real_orig_prefix STREQUAL qtbi_real_new_prefix) - set(qtbi_new_prefix "${qtbi_orig_prefix}") - endif() - endif() + qt_internal_new_prefix(qtbi_new_prefix + "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}" + "${qtbi_orig_prefix}") if(NOT qtbi_orig_staging_prefix STREQUAL "" AND "${CMAKE_STAGING_PREFIX}" STREQUAL "" AND NOT QT_BUILD_INTERNALS_NO_FORCE_SET_STAGING_PREFIX) - set(CMAKE_STAGING_PREFIX "${qtbi_new_prefix}" CACHE PATH + qt_internal_new_prefix(qtbi_new_staging_prefix + "${qtbi_new_prefix}" + "${qtbi_orig_staging_prefix}") + set(CMAKE_STAGING_PREFIX "${qtbi_new_staging_prefix}" CACHE PATH "Staging path prefix, prepended onto install directories on the host machine." FORCE) set(qtbi_new_prefix "${qtbi_orig_prefix}") endif() set(CMAKE_INSTALL_PREFIX "${qtbi_new_prefix}" CACHE PATH "Install path prefix, prepended onto install directories." FORCE) unset(qtbi_orig_prefix) - unset(qtbi_real_orig_prefix) unset(qtbi_new_prefix) - unset(qtbi_real_new_prefix) unset(qtbi_orig_staging_prefix) + unset(qtbi_new_staging_prefix) endif() # Propagate developer builds to other modules via BuildInternals package. @@ -72,6 +87,11 @@ set(QT_BUILD_BENCHMARKS @QT_BUILD_BENCHMARKS@ CACHE BOOL "Build Qt Benchmarks") set(QT_BUILD_MANUAL_TESTS @QT_BUILD_MANUAL_TESTS@ CACHE BOOL "Build Qt manual tests") set(QT_BUILD_MINIMAL_STATIC_TESTS @QT_BUILD_MINIMAL_STATIC_TESTS@ CACHE BOOL "Build minimal subset of tests for static Qt builds") +set(QT_BUILD_MINIMAL_ANDROID_MULTI_ABI_TESTS @QT_BUILD_MINIMAL_ANDROID_MULTI_ABI_TESTS@ CACHE BOOL + "Build minimal subset of tests for Android multi-ABI Qt builds") + +set(QT_BUILD_TESTS_BATCHED @QT_BUILD_TESTS_BATCHED@ CACHE BOOL + "Should all tests be batched into a single binary.") set(QT_BUILD_TESTS_BY_DEFAULT @QT_BUILD_TESTS_BY_DEFAULT@ CACHE BOOL "Should tests be built as part of the default 'all' target.") @@ -86,6 +106,16 @@ set(QT_BUILD_EXAMPLES_AS_EXTERNAL "@QT_BUILD_EXAMPLES_AS_EXTERNAL@" CACHE BOOL # Propagate usage of ccache. set(QT_USE_CCACHE @QT_USE_CCACHE@ CACHE BOOL "Enable the use of ccache") +# Propagate usage of vcpkg, ON by default. +set(QT_USE_VCPKG @QT_USE_VCPKG@ CACHE BOOL "Enable the use of vcpkg") + +# Propagate usage of unity build. +set(QT_UNITY_BUILD @QT_UNITY_BUILD@ CACHE BOOL "Enable unity (jumbo) build") +set(QT_UNITY_BUILD_BATCH_SIZE "@QT_UNITY_BUILD_BATCH_SIZE@" CACHE STRING "Unity build batch size") + +# Propragate the value of WARNINGS_ARE_ERRORS. +set(WARNINGS_ARE_ERRORS "@WARNINGS_ARE_ERRORS@" CACHE BOOL "Build Qt with warnings as errors") + # Propagate usage of versioned hard link. set(QT_CREATE_VERSIONED_HARD_LINK "@QT_CREATE_VERSIONED_HARD_LINK@" CACHE BOOL "Enable the use of versioned hard link") @@ -105,42 +135,5 @@ if(NOT DEFINED QT_MAX_NEW_POLICY_CMAKE_VERSION) set(QT_MAX_NEW_POLICY_CMAKE_VERSION "@max_new_policy_version@") endif() -get_property(__qt_internal_extras_is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) - -# We want the same build type to be used when configuring all Qt repos or standalone -# tests or single tests. -# To do that, we need to force-set the CMAKE_BUILD_TYPE cache var because CMake itself -# initializes it with the value of CMAKE_BUILD_TYPE_INIT at the start of project -# configuration, so we need to override it. -# Note the value of CMAKE_BUILD_TYPE_INIT is different based on the platform, most -# Linux and macOS platforms will have it empty, but Windows platforms will have a value. -# -# We can't reliably differentiate between a value set on the command line by the user -# and one set by CMake, so we use a few heuristics: -# 1) When using a qt.toolchain.cmake file, we rely on the toolchain file to tell us -# if a value was set by the user at initial configure time. On a 2nd run there will -# always be a value in the cache, but at that point we've already set it to whatever it needs -# to be. -# 2) If a toolchain file is not used, we rely on the value of the CMake internal -# CMAKE_BUILD_TYPE_INIT variable. -# This won't work reliably on Windows where CMAKE_BUILD_TYPE_INIT is non-empty. -# -# Both cases won't handle an empty "" config set by the user, but we claim that's an -# unsupported config when building Qt. -# -# Allow an opt out when QT_NO_FORCE_SET_CMAKE_BUILD_TYPE is set. -# Finally, don't set the variable if a multi-config generator is used. This can happen -# when qtbase is built with a single config, but a test is built with a multi-config generator. -function(qt_internal_force_set_cmake_build_type_conditionally value) - # STREQUAL check needs to be expanded variables because an undefined var is not equal to an - # empty defined var. - if("${CMAKE_BUILD_TYPE}" STREQUAL "${CMAKE_BUILD_TYPE_INIT}" - AND NOT __qt_toolchain_cmake_build_type_before_project_call - AND NOT QT_NO_FORCE_SET_CMAKE_BUILD_TYPE - AND NOT __qt_internal_extras_is_multi_config) - set(CMAKE_BUILD_TYPE "${value}" CACHE STRING "Choose the type of build." FORCE) - endif() -endfunction() - # Extra set of exported variables @QT_EXTRA_BUILD_INTERNALS_VARS@ |