summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorAlexey Edelev <alexey.edelev@qt.io>2021-12-23 13:20:21 +0100
committerAlexey Edelev <alexey.edelev@qt.io>2022-01-04 12:54:15 +0100
commitdcc2704d17bda08e6dc7783559ccbfd864dd4339 (patch)
treed239b158ed94c87c555ef8ef00f15ea9d5220fd1 /CMakeLists.txt
parent18e62ed3b73849ea985f592fea10255de8bd440c (diff)
Use IS_SYMLINK condition instead of REALPATH when checking BINARY_DIR
For case-insensitive file systems, the REALPATH file component may return file paths in a different case than ABSOULEPATH. We use REALPATH to detect symlinks. In case-sensitive file systems there still might be the situation when /path/to/Build is a symlink to the /path/to/build, so we cannot make the comparison case-insensitive. Use the IS_SYMLINK check instead. Pick-to: 6.2 6.3 Fixes: QTBUG-99416 Change-Id: Idf998b9e09837a834139553fb822e05b2a0a1949 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt28
1 files changed, 16 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 963ed295bf..56fa1adb22 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,21 +12,25 @@ cmake_minimum_required(VERSION 3.16)
include(.cmake.conf)
# Bail out if any part of the build directory's path is symlinked.
-# The OS-level current working directory is always the real path and some
-# parts of the build system only deal with that path, which causes confusion
-# when compared to the logical working directory maintained by the shell and
-# passed on the command line.
-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. \
+function(qt_internal_check_if_path_has_symlinks path)
+ get_filename_component(dir "${path}" ABSOLUTE)
+ while(TRUE)
+ if(IS_SYMLINK "${dir}")
+ message(FATAL_ERROR "The path \"${path}\" contains symlinks. \
This is not supported. Possible solutions:
- map directories using a transparent mechanism such as mount --bind
- pass the real path of the build directory to CMake, e.g. using \
-cd $(realpath <build_dir>) before invoking cmake <source_dir>.")
-endif()
-unset(build_dir_absolute)
-unset(build_dir_realpath)
+cd $(realpath <path>) before invoking cmake <source_dir>.")
+ endif()
+
+ set(prev_dir "${dir}")
+ get_filename_component(dir "${dir}" DIRECTORY)
+ if("${dir}" STREQUAL "${prev_dir}")
+ return()
+ endif()
+ endwhile()
+endfunction()
+qt_internal_check_if_path_has_symlinks("${CMAKE_BINARY_DIR}")
# Run auto detection routines, but not when doing standalone tests. In that case, the detection
# results are taken from either QtBuildInternals or the qt.toolchain.cmake file. Also, inhibit