diff --git a/CMakeLists.txt b/CMakeLists.txt index f4d7b44159..c774e297ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 ) before invoking cmake .") + 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 ) before invoking cmake . + ]]) + 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}") diff --git a/cmake/QtSetup.cmake b/cmake/QtSetup.cmake index 262b60d171..7efb1a3b06 100644 --- a/cmake/QtSetup.cmake +++ b/cmake/QtSetup.cmake @@ -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)