Skip to content

ExternalProject,FetchContent: Avoid error if CMAKE_DISABLE_SOURCE_CHANGES is true

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 (closed)

Edited by Craig Scott

Merge request reports