diff options
author | Alexey Edelev <alexey.edelev@qt.io> | 2021-12-23 13:20:21 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-01-04 19:02:56 +0000 |
commit | 52a84c250877e45b93e9bd3252b1f350ef613985 (patch) | |
tree | 8de37dbc54199fd386488724ff1f38fb6430917c /CMakeLists.txt | |
parent | ac7a9907cbfabb6c0f4ea5cd64302cd3c69b1646 (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.
Fixes: QTBUG-99416
Change-Id: Idf998b9e09837a834139553fb822e05b2a0a1949
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit dcc2704d17bda08e6dc7783559ccbfd864dd4339)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c272ab6f05..0c8d2f44f2 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 |