From 33af62db3747bb6fcb7490ef2d2abc5bb53925b6 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 19 Jan 2022 13:13:12 +0100 Subject: 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 Reviewed-by: Joerg Bornemann --- cmake/QtPostProcessHelpers.cmake | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'cmake/QtPostProcessHelpers.cmake') 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() -- cgit v1.2.3