From a3b9e3459f02d23c66b2a7fa5e2ea6fac03bbe82 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Tue, 10 Nov 2020 15:00:13 +0100 Subject: [PATCH] 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 --- cmake/QtAutoDetect.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmake/QtAutoDetect.cmake b/cmake/QtAutoDetect.cmake index 33ecef4a65..4518078d8d 100644 --- a/cmake/QtAutoDetect.cmake +++ b/cmake/QtAutoDetect.cmake @@ -5,6 +5,15 @@ # Make sure to not run detection when building standalone tests, because the detection was already # 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) # Auto-detect NDK 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}") endfunction() +qt_auto_detect_cmake_generator() qt_auto_detect_cyclic_toolchain() qt_auto_detect_cmake_config() qt_auto_detect_darwin()