mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 19:00:54 -06:00
FetchContent: Relative SOURCE_DIR override cannot be a hard error
Fixes: #21624
This commit is contained in:
@@ -1053,7 +1053,14 @@ function(FetchContent_Populate contentName)
|
||||
# so no population is required. The build directory may still be specified
|
||||
# by the declared details though.
|
||||
|
||||
if(NOT EXISTS "${FETCHCONTENT_SOURCE_DIR_${contentNameUpper}}")
|
||||
if(NOT IS_ABSOLUTE "${FETCHCONTENT_SOURCE_DIR_${contentNameUpper}}")
|
||||
# Don't check this directory because we don't know what location it is
|
||||
# expected to be relative to. We can't make this a hard error for backward
|
||||
# compatibility reasons.
|
||||
message(WARNING "Relative source directory specified. This is not safe, "
|
||||
"as it depends on the calling directory scope.\n"
|
||||
" FETCHCONTENT_SOURCE_DIR_${contentNameUpper} --> ${FETCHCONTENT_SOURCE_DIR_${contentNameUpper}}")
|
||||
elseif(NOT EXISTS "${FETCHCONTENT_SOURCE_DIR_${contentNameUpper}}")
|
||||
message(FATAL_ERROR "Manually specified source directory is missing:\n"
|
||||
" FETCHCONTENT_SOURCE_DIR_${contentNameUpper} --> ${FETCHCONTENT_SOURCE_DIR_${contentNameUpper}}")
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
*Relative source directory specified. This is not safe, as it depends on
|
||||
*the calling directory scope.
|
||||
+ *FETCHCONTENT_SOURCE_DIR_WITHPROJECT --> WithProject
|
||||
@@ -0,0 +1 @@
|
||||
include(ManualSourceDirectory.cmake)
|
||||
@@ -21,6 +21,11 @@ run_cmake_with_options(ManualSourceDirectory
|
||||
run_cmake_with_options(ManualSourceDirectoryMissing
|
||||
-D "FETCHCONTENT_SOURCE_DIR_WITHPROJECT=${CMAKE_CURRENT_LIST_DIR}/ADirThatDoesNotExist"
|
||||
)
|
||||
# Need to use :STRING to prevent CMake from automatically converting it to an
|
||||
# absolute path
|
||||
run_cmake_with_options(ManualSourceDirectoryRelative
|
||||
-D "FETCHCONTENT_SOURCE_DIR_WITHPROJECT:STRING=WithProject"
|
||||
)
|
||||
|
||||
function(run_FetchContent_DirOverrides)
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/DirOverrides-build)
|
||||
|
||||
Reference in New Issue
Block a user