Be more helpful about the symlinked build directory problem

- Explain why a symlinked build dir won't work
- Add another workaround suggestion that works well in my case

Change-Id: I3f7eaeac2974e037587941f6f761fbcb262c4631
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Andreas Hartmetz 2021-05-14 14:48:19 +02:00 committed by Andreas Hartmetz
parent 861647e8a5
commit 27d9c0542c

View File

@ -8,12 +8,19 @@ 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.
# 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. \
This is not supported. Please use some other - transparent - mechanism to map directories.")
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)