diff options
author | Craig Scott <craig.scott@crascit.com> | 2024-05-18 09:04:39 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2024-05-18 09:05:03 (GMT) |
commit | 2d653179dcf55d98c10be1eba10f1cd075c9105c (patch) | |
tree | 525a364b3506b45b7017a4a44fd0bd24e6ecf827 /Tests/RunCMake | |
parent | ff12b19786557560ec24bc5ad6a084dd6e96616c (diff) | |
parent | 7bf15e49a848b2ff0afe2697027935e7bc9e4992 (diff) | |
download | CMake-2d653179dcf55d98c10be1eba10f1cd075c9105c.zip CMake-2d653179dcf55d98c10be1eba10f1cd075c9105c.tar.gz CMake-2d653179dcf55d98c10be1eba10f1cd075c9105c.tar.bz2 |
Merge topic 'fetchcontent-direct'
7bf15e49a8 ExternalProject: Fix misleading git update output
b2496bf14c FetchContent: Populate directly without a sub-build
173daad58d ExternalProject: Move more internal commands out of main file
462e583267 ExternalProject: Switch download, update and patch to use _EP_ vars
0ccc8e340d ExternalProject: Provide ExternalProject_Add keywords through a macro
91e1015722 ExternalProject: Don't treat YES as a keyword
a1743ce1ef ExternalProject: Fix minor formatting error
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: scivision <michael@scivision.dev>
Merge-request: !9513
Diffstat (limited to 'Tests/RunCMake')
19 files changed, 105 insertions, 54 deletions
diff --git a/Tests/RunCMake/CMP0135/CMP0135-WARN-stderr.txt b/Tests/RunCMake/CMP0135/CMP0135-WARN-stderr.txt index 6bf944e..1632d63 100644 --- a/Tests/RunCMake/CMP0135/CMP0135-WARN-stderr.txt +++ b/Tests/RunCMake/CMP0135/CMP0135-WARN-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning \(dev\) at .*/Modules/ExternalProject.cmake:[0-9]+ \(message\): +CMake Warning \(dev\) at .*/Modules/ExternalProject/shared_internal_commands\.cmake:[0-9]+ \(message\): The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is not set\. The policy's OLD behavior will be used\. When using a URL download, the timestamps of extracted files should preferably be that of @@ -9,7 +9,7 @@ CMake Warning \(dev\) at .*/Modules/ExternalProject.cmake:[0-9]+ \(message\): DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this robustness issue\. .* -CMake Warning \(dev\) at .*/Modules/FetchContent.cmake:[0-9]+ \(message\): +CMake Warning \(dev\) at .*/Modules/FetchContent\.cmake:[0-9]+ \(message\): The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is not set\. The policy's OLD behavior will be used\. When using a URL download, the timestamps of extracted files should preferably be that of diff --git a/Tests/RunCMake/ExternalProject/NoOptions-stderr.txt b/Tests/RunCMake/ExternalProject/NoOptions-stderr.txt index 2fc7d29..72c4b81 100644 --- a/Tests/RunCMake/ExternalProject/NoOptions-stderr.txt +++ b/Tests/RunCMake/ExternalProject/NoOptions-stderr.txt @@ -1,4 +1,4 @@ -^CMake Error at .*/Modules/ExternalProject.cmake:[0-9]+ \(message\): +^CMake Error at .*/Modules/ExternalProject/shared_internal_commands\.cmake:[0-9]+ \(message\): No download info given for 'MyProj' and its source directory: .*/Tests/RunCMake/ExternalProject/NoOptions-build/MyProj-prefix/src/MyProj diff --git a/Tests/RunCMake/ExternalProject/SourceEmpty-stderr.txt b/Tests/RunCMake/ExternalProject/SourceEmpty-stderr.txt index 07c6e87..8789dde 100644 --- a/Tests/RunCMake/ExternalProject/SourceEmpty-stderr.txt +++ b/Tests/RunCMake/ExternalProject/SourceEmpty-stderr.txt @@ -1,4 +1,4 @@ -^CMake Error at .*/Modules/ExternalProject.cmake:[0-9]+ \(message\): +^CMake Error at .*/Modules/ExternalProject/shared_internal_commands\.cmake:[0-9]+ \(message\): No download info given for 'MyProj' and its source directory: .*/Tests/RunCMake/ExternalProject/SourceEmpty-build/SourceEmpty diff --git a/Tests/RunCMake/ExternalProject/SourceMissing-stderr.txt b/Tests/RunCMake/ExternalProject/SourceMissing-stderr.txt index 373f6e3..9ff2681 100644 --- a/Tests/RunCMake/ExternalProject/SourceMissing-stderr.txt +++ b/Tests/RunCMake/ExternalProject/SourceMissing-stderr.txt @@ -1,4 +1,4 @@ -^CMake Error at .*/Modules/ExternalProject.cmake:[0-9]+ \(message\): +^CMake Error at .*/Modules/ExternalProject/shared_internal_commands\.cmake:[0-9]+ \(message\): No download info given for 'MyProj' and its source directory: .*/Tests/RunCMake/ExternalProject/SourceMissing-build/SourceMissing diff --git a/Tests/RunCMake/ExternalProject/TLSVersionBadArg-stderr.txt b/Tests/RunCMake/ExternalProject/TLSVersionBadArg-stderr.txt index 1231797..f0973ba 100644 --- a/Tests/RunCMake/ExternalProject/TLSVersionBadArg-stderr.txt +++ b/Tests/RunCMake/ExternalProject/TLSVersionBadArg-stderr.txt @@ -1,9 +1,9 @@ ^CMake Error at [^ -]*/Modules/ExternalProject\.cmake:[0-9]+ \(message\): +]*/Modules/ExternalProject/shared_internal_commands\.cmake:[0-9]+ \(message\): TLS_VERSION 'bad-arg' not known Call Stack \(most recent call first\): [^ -]*/Modules/ExternalProject\.cmake:[0-9]+ \(_ep_get_tls_version\) +]*/Modules/ExternalProject/shared_internal_commands\.cmake:[0-9]+ \(_ep_get_tls_version\) [^ ]*/Modules/ExternalProject\.cmake:[0-9]+ \(_ep_add_download_command\) TLSVersionBadArg\.cmake:[0-9]+ \(ExternalProject_Add\) diff --git a/Tests/RunCMake/ExternalProject/TLSVersionBadEnv-stderr.txt b/Tests/RunCMake/ExternalProject/TLSVersionBadEnv-stderr.txt index 38b0fb8..4069159 100644 --- a/Tests/RunCMake/ExternalProject/TLSVersionBadEnv-stderr.txt +++ b/Tests/RunCMake/ExternalProject/TLSVersionBadEnv-stderr.txt @@ -1,9 +1,9 @@ ^CMake Error at [^ -]*/Modules/ExternalProject\.cmake:[0-9]+ \(message\): +]*/Modules/ExternalProject/shared_internal_commands\.cmake:[0-9]+ \(message\): ENV{CMAKE_TLS_VERSION} 'bad-env' not known Call Stack \(most recent call first\): [^ -]*/Modules/ExternalProject\.cmake:[0-9]+ \(_ep_get_tls_version\) +]*/Modules/ExternalProject/shared_internal_commands\.cmake:[0-9]+ \(_ep_get_tls_version\) [^ ]*/Modules/ExternalProject\.cmake:[0-9]+ \(_ep_add_download_command\) TLSVersionBadEnv\.cmake:[0-9]+ \(ExternalProject_Add\) diff --git a/Tests/RunCMake/ExternalProject/TLSVersionBadVar-stderr.txt b/Tests/RunCMake/ExternalProject/TLSVersionBadVar-stderr.txt index aaec60b..a5f7d64 100644 --- a/Tests/RunCMake/ExternalProject/TLSVersionBadVar-stderr.txt +++ b/Tests/RunCMake/ExternalProject/TLSVersionBadVar-stderr.txt @@ -1,9 +1,9 @@ ^CMake Error at [^ -]*/Modules/ExternalProject\.cmake:[0-9]+ \(message\): +]*/Modules/ExternalProject/shared_internal_commands\.cmake:[0-9]+ \(message\): CMAKE_TLS_VERSION 'bad-var' not known Call Stack \(most recent call first\): [^ -]*/Modules/ExternalProject\.cmake:[0-9]+ \(_ep_get_tls_version\) +]*/Modules/ExternalProject/shared_internal_commands\.cmake:[0-9]+ \(_ep_get_tls_version\) [^ ]*/Modules/ExternalProject\.cmake:[0-9]+ \(_ep_add_download_command\) TLSVersionBadVar\.cmake:[0-9]+ \(ExternalProject_Add\) diff --git a/Tests/RunCMake/FetchContent/CMakeLists.txt b/Tests/RunCMake/FetchContent/CMakeLists.txt index 3cc2e43..eb0b40c 100644 --- a/Tests/RunCMake/FetchContent/CMakeLists.txt +++ b/Tests/RunCMake/FetchContent/CMakeLists.txt @@ -4,4 +4,10 @@ project(${RunCMake_TEST} NONE) # Tests assume no previous downloads in the output directory file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/_deps) +if(CMP0168 STREQUAL "NEW") + cmake_policy(SET CMP0168 NEW) + string(REGEX REPLACE "-direct$" "" RunCMake_TEST "${RunCMake_TEST}") +else() + cmake_policy(SET CMP0168 OLD) +endif() include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/FetchContent/DownloadFile.cmake b/Tests/RunCMake/FetchContent/DownloadFile.cmake index 741b6d3..e21ae28 100644 --- a/Tests/RunCMake/FetchContent/DownloadFile.cmake +++ b/Tests/RunCMake/FetchContent/DownloadFile.cmake @@ -1,8 +1,12 @@ include(FetchContent) +# The file hash depends on the line endings used by git +file(MD5 ${CMAKE_CURRENT_LIST_DIR}/dummyFile.txt md5_hash) + FetchContent_Declare( t1 URL ${CMAKE_CURRENT_LIST_DIR}/dummyFile.txt + URL_HASH MD5=${md5_hash} DOWNLOAD_NO_EXTRACT YES ) diff --git a/Tests/RunCMake/FetchContent/DownloadTwice-direct-result.txt b/Tests/RunCMake/FetchContent/DownloadTwice-direct-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FetchContent/DownloadTwice-direct-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FetchContent/DownloadTwice-direct-stderr.txt b/Tests/RunCMake/FetchContent/DownloadTwice-direct-stderr.txt new file mode 100644 index 0000000..e793902 --- /dev/null +++ b/Tests/RunCMake/FetchContent/DownloadTwice-direct-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .*/Modules/FetchContent\.cmake:[0-9]+ \(message\): + Content t1 already populated in diff --git a/Tests/RunCMake/FetchContent/MakeAvailableUndeclared-direct-result.txt b/Tests/RunCMake/FetchContent/MakeAvailableUndeclared-direct-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FetchContent/MakeAvailableUndeclared-direct-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FetchContent/MakeAvailableUndeclared-direct-stderr.txt b/Tests/RunCMake/FetchContent/MakeAvailableUndeclared-direct-stderr.txt new file mode 100644 index 0000000..9c3fc27 --- /dev/null +++ b/Tests/RunCMake/FetchContent/MakeAvailableUndeclared-direct-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .*/Modules/FetchContent\.cmake:[0-9]+ \(message\): + No content details recorded for NoDetails diff --git a/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing-direct-result.txt b/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing-direct-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing-direct-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing-direct-stderr.txt b/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing-direct-stderr.txt new file mode 100644 index 0000000..7ecb06b --- /dev/null +++ b/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing-direct-stderr.txt @@ -0,0 +1,2 @@ + *Manually specified source directory is missing: ++ *FETCHCONTENT_SOURCE_DIR_WITHPROJECT --> .*/ADirThatDoesNotExist diff --git a/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing.cmake b/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing.cmake index 0e24c1a..82e5c46 100644 --- a/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing.cmake +++ b/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing.cmake @@ -1,3 +1,4 @@ +message(STATUS "FETCHCONTENT_SOURCE_DIR_WITHPROJECT = ${FETCHCONTENT_SOURCE_DIR_WITHPROJECT}") include(FetchContent) FetchContent_Declare( diff --git a/Tests/RunCMake/FetchContent/ManualSourceDirectoryRelative-direct-stderr.txt b/Tests/RunCMake/FetchContent/ManualSourceDirectoryRelative-direct-stderr.txt new file mode 100644 index 0000000..3defcb4 --- /dev/null +++ b/Tests/RunCMake/FetchContent/ManualSourceDirectoryRelative-direct-stderr.txt @@ -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 diff --git a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake index 0f443a7..72a458c 100644 --- a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake +++ b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake @@ -2,81 +2,107 @@ include(RunCMake) unset(RunCMake_TEST_NO_CLEAN) -run_cmake(MissingDetails) -run_cmake(DirectIgnoresDetails) -run_cmake(FirstDetailsWin) -run_cmake(DownloadTwice) -run_cmake(DownloadFile) -run_cmake(IgnoreToolchainFile) -run_cmake(SameGenerator) -run_cmake(System) -run_cmake(VarDefinitions) -run_cmake(VarPassthroughs) -run_cmake(GetProperties) -run_cmake(UsesTerminalOverride) -run_cmake(MakeAvailable) -run_cmake(MakeAvailableTwice) -run_cmake(MakeAvailableUndeclared) -run_cmake(VerifyHeaderSet) +function(run_cmake_with_cmp0168 name) + run_cmake_with_options("${name}" -D CMP0168=OLD ${ARGN}) + run_cmake_with_options("${name}-direct" -D CMP0168=NEW ${ARGN}) +endfunction() + +# Won't get to the part where CMP0168 matters +run_cmake_with_options(MissingDetails -D CMP0168=NEW) + +# These are testing specific aspects of the sub-build +run_cmake_with_options(SameGenerator -D CMP0168=OLD) +run_cmake_with_options(VarPassthroughs -D CMP0168=OLD) -run_cmake_with_options(FindDependencyExport +run_cmake_with_cmp0168(DirectIgnoresDetails) +run_cmake_with_cmp0168(FirstDetailsWin) +run_cmake_with_cmp0168(DownloadTwice) +run_cmake_with_cmp0168(DownloadFile) +run_cmake_with_cmp0168(IgnoreToolchainFile) +run_cmake_with_cmp0168(System) +run_cmake_with_cmp0168(VarDefinitions) +run_cmake_with_cmp0168(GetProperties) +run_cmake_with_cmp0168(UsesTerminalOverride) +run_cmake_with_cmp0168(MakeAvailable) +run_cmake_with_cmp0168(MakeAvailableTwice) +run_cmake_with_cmp0168(MakeAvailableUndeclared) +run_cmake_with_cmp0168(VerifyHeaderSet) + +run_cmake_with_cmp0168(FindDependencyExport -D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=${CMAKE_CURRENT_LIST_DIR}/FindDependencyExportDP.cmake" ) -run_cmake_with_options(ManualSourceDirectory +run_cmake_with_cmp0168(ManualSourceDirectory -D "FETCHCONTENT_SOURCE_DIR_WITHPROJECT=${CMAKE_CURRENT_LIST_DIR}/WithProject" ) -run_cmake_with_options(ManualSourceDirectoryMissing +run_cmake_with_cmp0168(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 +run_cmake_with_cmp0168(ManualSourceDirectoryRelative -D "FETCHCONTENT_SOURCE_DIR_WITHPROJECT:STRING=WithProject" ) -function(run_FetchContent_DirOverrides) - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/DirOverrides-build) +function(run_FetchContent_DirOverrides cmp0168) + if(cmp0168 STREQUAL "NEW") + set(suffix "-direct") + else() + set(suffix "") + endif() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/DirOverrides${suffix}-build) file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") - run_cmake(DirOverrides) + run_cmake_with_options(DirOverrides${suffix} -D CMP0168=${cmp0168}) set(RunCMake_TEST_NO_CLEAN 1) - run_cmake_with_options(DirOverridesDisconnected + run_cmake_with_options(DirOverridesDisconnected${suffix} + -D CMP0168=${cmp0168} -D FETCHCONTENT_FULLY_DISCONNECTED=YES ) endfunction() -run_FetchContent_DirOverrides() +run_FetchContent_DirOverrides(OLD) +run_FetchContent_DirOverrides(NEW) set(RunCMake_TEST_OUTPUT_MERGE 1) -run_cmake(PreserveEmptyArgs) +run_cmake_with_cmp0168(PreserveEmptyArgs) set(RunCMake_TEST_OUTPUT_MERGE 0) -# We need to pass through CMAKE_GENERATOR and CMAKE_MAKE_PROGRAM -# to ensure the test can run on machines where the build tool -# isn't on the PATH. Some build slaves explicitly test with such -# an arrangement (e.g. to test with spaces in the path). We also -# pass through the platform and toolset for completeness, even -# though we don't build anything, just in case this somehow affects -# the way the build tool is invoked. -run_cmake_command(ScriptMode - ${CMAKE_COMMAND} - -DCMAKE_GENERATOR=${RunCMake_GENERATOR} - -DCMAKE_GENERATOR_PLATFORM=${RunCMake_GENERATOR_PLATFORM} - -DCMAKE_GENERATOR_TOOLSET=${RunCMake_GENERATOR_TOOLSET} - -DCMAKE_MAKE_PROGRAM=${RunCMake_MAKE_PROGRAM} - -P ${CMAKE_CURRENT_LIST_DIR}/ScriptMode.cmake -) - function(run_FetchContent_ExcludeFromAll) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ExcludeFromAll-build) file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") - run_cmake(ExcludeFromAll) + # We're testing FetchContent_MakeAvailable()'s add_subdirectory() behavior, + # so it doesn't matter if we use OLD or NEW for CMP0168, but NEW is faster. + run_cmake(ExcludeFromAll -D CMP0168=NEW) set(RunCMake_TEST_NO_CLEAN 1) run_cmake_command(ExcludeFromAll-build ${CMAKE_COMMAND} --build .) endfunction() run_FetchContent_ExcludeFromAll() + +# Script mode testing requires more care for CMP0168 set to OLD. +# We need to pass through CMAKE_GENERATOR and CMAKE_MAKE_PROGRAM +# to ensure the test can run on machines where the build tool +# isn't on the PATH. Some build machines explicitly test with such +# an arrangement (e.g. to test with spaces in the path). We also +# pass through the platform and toolset for completeness, even +# though we don't build anything, just in case this somehow affects +# the way the build tool is invoked. +run_cmake_command(ScriptMode + ${CMAKE_COMMAND} + -DCMP0168=OLD + -DCMAKE_GENERATOR=${RunCMake_GENERATOR} + -DCMAKE_GENERATOR_PLATFORM=${RunCMake_GENERATOR_PLATFORM} + -DCMAKE_GENERATOR_TOOLSET=${RunCMake_GENERATOR_TOOLSET} + -DCMAKE_MAKE_PROGRAM=${RunCMake_MAKE_PROGRAM} + -P ${CMAKE_CURRENT_LIST_DIR}/ScriptMode.cmake +) +# CMP0168 NEW doesn't need a build tool or generator, so don't set them. +run_cmake_command(ScriptMode-direct + ${CMAKE_COMMAND} + -DCMP0168=NEW + -P ${CMAKE_CURRENT_LIST_DIR}/ScriptMode.cmake +) diff --git a/Tests/RunCMake/FetchContent/ScriptMode.cmake b/Tests/RunCMake/FetchContent/ScriptMode.cmake index 0a93d62..bf66140 100644 --- a/Tests/RunCMake/FetchContent/ScriptMode.cmake +++ b/Tests/RunCMake/FetchContent/ScriptMode.cmake @@ -1,3 +1,5 @@ +cmake_policy(SET CMP0168 ${CMP0168}) + include(FetchContent) file(WRITE tmpFile.txt "Generated contents, not important") |