mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-08 06:40:48 -06:00
The file(MAKE_DIRECTORY) implementation checks whether a path is allowed to be written to before it checks if it already exists. For the scenario where a SOURCE_DIR is an existing directory within the main project's source directory, this triggers a fatal error if CMAKE_DISABLE_SOURCE_CHANGES is set to true for ExternalProject, and some FetchContent scenarios. Therefore, add an explicit check for existence first to avoid making such error-triggering calls. Fixes: #21872
17 lines
528 B
CMake
17 lines
528 B
CMake
# We're providing a pre-existing source directory. Make sure we don't trigger
|
|
# an error if the undocumented but used-in-the-wild CMAKE_DISABLE_SOURCE_CHANGES
|
|
# variable is set.
|
|
set(CMAKE_DISABLE_SOURCE_CHANGES TRUE)
|
|
|
|
include(ExternalProject)
|
|
|
|
ExternalProject_Add(source_dir_existing
|
|
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/Foo"
|
|
DOWNLOAD_COMMAND "${CMAKE_COMMAND}" -E echo "Download command executed"
|
|
UPDATE_COMMAND ""
|
|
CONFIGURE_COMMAND ""
|
|
BUILD_COMMAND ""
|
|
TEST_COMMAND ""
|
|
INSTALL_COMMAND ""
|
|
)
|