Introduce QT_ALLOW_SYMLINK_IN_PATHS flag

`QT_ALLOW_SYMLINK_IN_PATHS` disables the
`qt_internal_check_if_path_has_symlinks` command. This allows people of
Homebrew to get their build working without having to patch the entire
function, as they currently do.

Pick-to: 6.5
Change-Id: I4fed3ca497684364eaabbdbc44f1e148e3f28bd7
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Amir Masoud Abdol 2023-05-02 14:07:41 +02:00
parent 4d404c2936
commit edabd36cbb
2 changed files with 22 additions and 5 deletions

View File

@ -38,11 +38,26 @@ function(qt_internal_check_if_path_has_symlinks path)
endwhile()
endif()
if(is_symlink)
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 <path>) before invoking cmake <source_dir>.")
set(possible_solutions_for_resolving_symlink [[
- 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 <path>) before invoking cmake <source_dir>.
]])
if(QT_ALLOW_SYMLINK_IN_PATHS)
# In some cases, e.g., Homebrew, it is beneficial to skip this check.
# Before this, Homebrew had to patch this out to be able to get their build.
message(WARNING
"The path \"${path}\" contains symlinks. "
"This is not recommended, and it may lead to unexpected issues. If you do "
"not have a good reason for enabling 'QT_ALLOW_SYMLINK_IN_PATHS', disable "
"it, and follow one of the following solutions: \n"
"${possible_solutions_for_resolving_symlink} ")
else()
message(FATAL_ERROR
"The path \"${path}\" contains symlinks. "
"This is not supported. Possible solutions: \n"
"${possible_solutions_for_resolving_symlink} ")
endif()
endif()
endfunction()
qt_internal_check_if_path_has_symlinks("${CMAKE_BINARY_DIR}")

View File

@ -352,6 +352,8 @@ if(QT_UNITY_BUILD)
set(CMAKE_UNITY_BUILD_BATCH_SIZE "${QT_UNITY_BUILD_BATCH_SIZE}")
endif()
option(QT_ALLOW_SYMLINK_IN_PATHS "Allows symlinks in paths." OFF)
# We need to clean up QT_FEATURE_*, but only once per configuration cycle
get_property(qt_feature_clean GLOBAL PROPERTY _qt_feature_clean)
if(NOT qt_feature_clean)