CMake: Bail when configuring multiple configurations and plain Ninja

Previously configuration would not error out if you configured Qt
with -DCMAKE_CONFIGURATION_TYPES=RelWithDebInfo;Debug -GNinja
instead you would get an error like

 CMake Error at cmake/QtBaseConfigureTests.cmake:51 (message):
 Failed to find compiled architecture detection executable at
 qtbase/build/config.tests/arch/RelWithDebInfo/architecture_test.exe

Note that Qt code tries to find the arch test in a RelWithDebInfo
directory but due to using single-config Ninja,
CMAKE_CONFIGURATION_TYPES is ignored, and the executable is placed
in a non-config specific folder.

Error out early in such a case, and mention that for multi-config
builds, the Ninja Multi-Config generator should be used.

Pick-to: 6.4
Change-Id: I0192185123be563671cbe154f968a03b7458e327
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Alexandru Croitor 2022-08-08 15:40:31 +02:00
parent 09a8283fb6
commit 0ce5c0a996

View File

@ -62,6 +62,12 @@ elseif(CMAKE_CONFIGURATION_TYPES)
message(STATUS
"Default build configuration set to '${CMAKE_NINJA_MULTI_DEFAULT_BUILD_TYPE}'.")
endif()
if(CMAKE_GENERATOR STREQUAL "Ninja")
message(FATAL_ERROR
"It's not possible to build multiple configurations with the single config Ninja "
"generator. Consider configuring with -G\"Ninja Multi-Config\" instead of -GNinja."
)
endif()
else()
message(STATUS "CMAKE_BUILD_TYPE was set to: '${CMAKE_BUILD_TYPE}'")
endif()