From 41aff1cd938457539fd6fd1009a3859de6b78095 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 17 Dec 2020 13:41:38 +0100 Subject: [PATCH] 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 Reviewed-by: Gatis Paeglis Reviewed-by: Liang Qi --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3557cad293c..5fb65fbd28a 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()