diff --git a/cmake/QtAutoDetect.cmake b/cmake/QtAutoDetect.cmake index dd5d8a6bd6..2fa103963a 100644 --- a/cmake/QtAutoDetect.cmake +++ b/cmake/QtAutoDetect.cmake @@ -172,8 +172,15 @@ function(qt_auto_detect_cmake_config) set(CMAKE_TRY_COMPILE_CONFIGURATION "${QT_MULTI_CONFIG_FIRST_CONFIG}" PARENT_SCOPE) if(CMAKE_GENERATOR STREQUAL "Ninja Multi-Config") + # Create build-.ninja files for all specified configurations. set(CMAKE_CROSS_CONFIGS "all" CACHE STRING "") + + # The configuration that will be considered the main one (for example when + # configuring standalone tests with a single-config generator like Ninja). set(CMAKE_DEFAULT_BUILD_TYPE "${QT_MULTI_CONFIG_FIRST_CONFIG}" CACHE STRING "") + + # By default when ninja is called without parameters, it will build all configurations. + set(CMAKE_DEFAULT_CONFIGS "all" CACHE STRING "") endif() endif() endfunction() diff --git a/cmake/QtPostProcess.cmake b/cmake/QtPostProcess.cmake index 6d3c4cd240..d1db4686b8 100644 --- a/cmake/QtPostProcess.cmake +++ b/cmake/QtPostProcess.cmake @@ -381,7 +381,6 @@ function(qt_generate_build_internals_extra_cmake_code) if(QT_BUILD_STANDALONE_TESTS) set(CMAKE_BUILD_TYPE \"\${QT_MULTI_CONFIG_FIRST_CONFIG}\" CACHE STRING \"Choose the type of build.\" FORCE) endif()\n") - string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS "${multi_config_specific}") endif() if(CMAKE_CROSS_CONFIGS) @@ -392,6 +391,10 @@ endif()\n") string(APPEND ninja_multi_config_specific " set(CMAKE_DEFAULT_BUILD_TYPE \"${CMAKE_DEFAULT_BUILD_TYPE}\" CACHE STRING \"\")\n") endif() + if(CMAKE_DEFAULT_CONFIGS) + string(APPEND ninja_multi_config_specific + " set(CMAKE_DEFAULT_CONFIGS \"${CMAKE_DEFAULT_CONFIGS}\" CACHE STRING \"\")\n") + endif() if(ninja_multi_config_specific) qt_wrap_string_in_if_ninja_multi_config( "${ninja_multi_config_specific}"