CMake: Warn when building Qt with a generator other than Ninja

For now, we only support building Qt with the Ninja generator (and
Ninja Multi-Config).

Issue a warning when a different generator is used.
Allow opting out of the warning by passing
-DQT_SILENCE_CMAKE_GENERATOR_WARNING=ON.

Change-Id: I5faa5b0ca5fd42efc090ad2ccf4f896bd77e50ca
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexandru Croitor 2020-11-10 15:00:13 +01:00
parent fbf11e86ef
commit a3b9e3459f

View File

@ -5,6 +5,15 @@
# Make sure to not run detection when building standalone tests, because the detection was already # Make sure to not run detection when building standalone tests, because the detection was already
# done when initially configuring qtbase. # done when initially configuring qtbase.
function(qt_auto_detect_cmake_generator)
if(NOT CMAKE_GENERATOR MATCHES "Ninja" AND NOT QT_SILENCE_CMAKE_GENERATOR_WARNING)
message(WARNING
"The officially supported CMake generator for building Qt is Ninja. "
"You are using: '${CMAKE_GENERATOR}' instead. "
"Thus, you might encounter issues. Use at your own risk.")
endif()
endfunction()
function(qt_auto_detect_android) function(qt_auto_detect_android)
# Auto-detect NDK root # Auto-detect NDK root
if(NOT DEFINED CMAKE_ANDROID_NDK_ROOT AND DEFINED ANDROID_SDK_ROOT) if(NOT DEFINED CMAKE_ANDROID_NDK_ROOT AND DEFINED ANDROID_SDK_ROOT)
@ -294,6 +303,7 @@ function(qt_auto_detect_pch)
option(BUILD_WITH_PCH "Build Qt using precompiled headers?" "${default_value}") option(BUILD_WITH_PCH "Build Qt using precompiled headers?" "${default_value}")
endfunction() endfunction()
qt_auto_detect_cmake_generator()
qt_auto_detect_cyclic_toolchain() qt_auto_detect_cyclic_toolchain()
qt_auto_detect_cmake_config() qt_auto_detect_cmake_config()
qt_auto_detect_darwin() qt_auto_detect_darwin()