summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtAutoDetect.cmake11
-rw-r--r--cmake/QtBaseGlobalTargets.cmake2
-rw-r--r--cmake/qt.toolchain.cmake.in16
3 files changed, 25 insertions, 4 deletions
diff --git a/cmake/QtAutoDetect.cmake b/cmake/QtAutoDetect.cmake
index 2fa103963a..5c72bf39d8 100644
--- a/cmake/QtAutoDetect.cmake
+++ b/cmake/QtAutoDetect.cmake
@@ -185,6 +185,16 @@ function(qt_auto_detect_cmake_config)
endif()
endfunction()
+function(qt_auto_detect_cyclic_toolchain)
+ if(CMAKE_TOOLCHAIN_FILE AND CMAKE_TOOLCHAIN_FILE MATCHES "/qt.toolchain.cmake$")
+ message(FATAL_ERROR
+ "Woah there! You can't use the Qt generated qt.toolchain.cmake file to configure "
+ "qtbase, because that will create a toolchain file that includes itself!\n"
+ "Did you accidentally use qt-cmake to configure qtbase? Make sure to remove the "
+ "CMakeCache.txt file, and configure qtbase with 'cmake' instead of 'qt-cmake'.")
+ endif()
+endfunction()
+
function(qt_auto_detect_darwin)
if(APPLE)
# If no CMAKE_OSX_DEPLOYMENT_TARGET is provided, default to a value that Qt defines.
@@ -230,6 +240,7 @@ function(qt_auto_detect_pch)
option(BUILD_WITH_PCH "Build Qt using precompiled headers?" "${default_value}")
endfunction()
+qt_auto_detect_cyclic_toolchain()
qt_auto_detect_cmake_config()
qt_auto_detect_darwin()
qt_auto_detect_ios()
diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake
index d37c7f1cc0..5e97f0e66b 100644
--- a/cmake/QtBaseGlobalTargets.cmake
+++ b/cmake/QtBaseGlobalTargets.cmake
@@ -116,7 +116,7 @@ if(QT_HOST_PATH)
endif()
if(CMAKE_TOOLCHAIN_FILE)
- set(init_original_toolchain_file "set(qt_chainload_toolchain_file \"${CMAKE_TOOLCHAIN_FILE}\")")
+ set(init_original_toolchain_file "set(__qt_chainload_toolchain_file \"${CMAKE_TOOLCHAIN_FILE}\")")
endif()
if(VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
diff --git a/cmake/qt.toolchain.cmake.in b/cmake/qt.toolchain.cmake.in
index d623d9c0fb..e7af642c05 100644
--- a/cmake/qt.toolchain.cmake.in
+++ b/cmake/qt.toolchain.cmake.in
@@ -6,9 +6,19 @@
@init_vcpkg@
-if(qt_chainload_toolchain_file)
- include("${qt_chainload_toolchain_file}")
- unset(qt_chainload_toolchain_file)
+if(__qt_chainload_toolchain_file)
+ get_filename_component(__qt_chainload_toolchain_file_real_path
+ "${__qt_chainload_toolchain_file}" REALPATH)
+ if(__qt_chainload_toolchain_file_real_path STREQUAL CMAKE_CURRENT_LIST_FILE)
+ message(FATAL_ERROR
+ "Woah, the Qt toolchain file tried to include itself recusively! '${__qt_chainload_toolchain_file}' "
+ "Make sure to remove qtbase/CMakeCache.txt and reconfigure qtbase with 'cmake' "
+ "rather than 'qt-cmake', and then you can reconfigure your own project."
+ )
+ else()
+ include("${__qt_chainload_toolchain_file}")
+ endif()
+ unset(__qt_chainload_toolchain_file)
endif()
# Compute dynamically the Qt installation prefix from the location of this file. This allows