summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2020-12-17 13:41:38 +0100
committerJoerg Bornemann <joerg.bornemann@qt.io>2020-12-21 13:22:26 +0100
commit41aff1cd938457539fd6fd1009a3859de6b78095 (patch)
treeacd2d826a70d1bc6f2362de08586ef5a9b4c9215 /CMakeLists.txt
parentc6379e34993370e7e2208b51be384b738ce35817 (diff)
CMake: Bail out if the build dir is symlinked
Building Qt in a symlinked build directory leads to all kind of issues, like unnecessary rebuilds, strange compilation errors or already errors at configure time. Detect this situation and bail out early with an informative error message. Task-number: QTBUG-88418 Task-number: QTBUG-89559 Change-Id: I70c16e11a7eede7a183f6f56b73ea93f985312f3 Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io> Reviewed-by: Liang Qi <liang.qi@qt.io>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt10
1 files changed, 10 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3557cad293..5fb65fbd28 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,6 +8,16 @@ cmake_minimum_required(VERSION 3.16)
# Get the repo version and CMake policy details
include(.cmake.conf)
+# Bail out if parts of the build directory's components are symlinks.
+get_filename_component(build_dir_absolute "${CMAKE_BINARY_DIR}" ABSOLUTE)
+get_filename_component(build_dir_realpath "${CMAKE_BINARY_DIR}" REALPATH)
+if(NOT build_dir_absolute STREQUAL build_dir_realpath)
+ message(FATAL_ERROR "The build path \"${CMAKE_BINARY_DIR}\" contains symlinks. \
+This is not supported. Please use some other - transparent - mechanism to map directories.")
+endif()
+unset(build_dir_absolute)
+unset(build_dir_realpath)
+
# Early check to reduce chance of warning being lost in the output
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtCMakeVersionHelpers.cmake")
qt_internal_check_for_suitable_cmake_version()