summaryrefslogtreecommitdiffstats
path: root/cmake/QtPostProcessHelpers.cmake
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2022-01-19 13:13:12 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2022-01-21 14:24:09 +0100
commit33af62db3747bb6fcb7490ef2d2abc5bb53925b6 (patch)
tree9c6711f7a7d0c18660601dd74e0d47f62d9f6f28 /cmake/QtPostProcessHelpers.cmake
parent0d5dc56554988edb87cb1575220a107c8a1f9cc4 (diff)
CMake: Support overriding CMAKE_BUILD_TYPE per-repo or test
One might want to build qtbase in Release, but qtsvg or some test in Debug mode. Before if qtbase was configured as Release, there was no way to override that. Now we try to detect whether a custom build type was specified to qt-cmake / qt-configure-module / qt-cmake-standalone-test / qt-internal-configure-tests Note mixing won't work on Windows due to different C/C++ runtimes. Also, now we don't force set a single build type when a multi config generator is used as well as one opts out via the QT_NO_FORCE_SET_CMAKE_BUILD_TYPE variable. Pick-to: 6.2 6.3 Change-Id: I6dc4325087ff7f905ad677d87b0267e2f3e4693f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake/QtPostProcessHelpers.cmake')
-rw-r--r--cmake/QtPostProcessHelpers.cmake17
1 files changed, 10 insertions, 7 deletions
diff --git a/cmake/QtPostProcessHelpers.cmake b/cmake/QtPostProcessHelpers.cmake
index a9b295a9d6..60a745c0f5 100644
--- a/cmake/QtPostProcessHelpers.cmake
+++ b/cmake/QtPostProcessHelpers.cmake
@@ -519,12 +519,12 @@ function(qt_generate_build_internals_extra_cmake_code)
${INSTALL_CMAKE_NAMESPACE}BuildInternals/QtBuildInternalsExtra.cmake)
if(CMAKE_BUILD_TYPE)
- # Need to force set, because CMake itself initializes a value for CMAKE_BUILD_TYPE
- # at the start of project configuration (with an empty value),
- # so we need to force override it.
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
- "set(CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\" CACHE STRING \"Choose the type of build.\" FORCE)\n")
-
+ "
+set(__qt_internal_initial_qt_cmake_build_type \"${CMAKE_BUILD_TYPE}\")
+qt_internal_force_set_cmake_build_type_conditionally(
+ \"\${__qt_internal_initial_qt_cmake_build_type}\")
+")
endif()
if(CMAKE_CONFIGURATION_TYPES)
string(APPEND multi_config_specific
@@ -546,11 +546,14 @@ function(qt_generate_build_internals_extra_cmake_code)
"\nset(QT_MULTI_CONFIG_FIRST_CONFIG \"${QT_MULTI_CONFIG_FIRST_CONFIG}\")\n")
endif()
# When building standalone tests against a multi-config Qt, we want to choose the first
- # configuration, rather than default to Debug.
+ # configuration, rather than use CMake's default value.
+ # In the case of Windows, we definitely don't it to default to Debug, because that causes
+ # issues in the CI.
if(multi_config_specific)
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS "
if(QT_BUILD_STANDALONE_TESTS)
- set(CMAKE_BUILD_TYPE \"\${QT_MULTI_CONFIG_FIRST_CONFIG}\" CACHE STRING \"Choose the type of build.\" FORCE)
+ qt_internal_force_set_cmake_build_type_conditionally(
+ \"\${QT_MULTI_CONFIG_FIRST_CONFIG}\")
endif()\n")
endif()