diff options
Diffstat (limited to 'Tests/RunCMake/FetchContent')
9 files changed, 54 insertions, 2 deletions
diff --git a/Tests/RunCMake/FetchContent/DownloadFile.cmake b/Tests/RunCMake/FetchContent/DownloadFile.cmake new file mode 100644 index 0000000..741b6d3 --- /dev/null +++ b/Tests/RunCMake/FetchContent/DownloadFile.cmake @@ -0,0 +1,9 @@ +include(FetchContent) + +FetchContent_Declare( + t1 + URL ${CMAKE_CURRENT_LIST_DIR}/dummyFile.txt + DOWNLOAD_NO_EXTRACT YES +) + +FetchContent_Populate(t1) diff --git a/Tests/RunCMake/FetchContent/MakeAvailable-stdout.txt b/Tests/RunCMake/FetchContent/MakeAvailable-stdout.txt index 6e6c730..711de6b 100644 --- a/Tests/RunCMake/FetchContent/MakeAvailable-stdout.txt +++ b/Tests/RunCMake/FetchContent/MakeAvailable-stdout.txt @@ -1,2 +1,3 @@ Confirmation project has been added +.*Confirmation subproject has been added .*Confirmation script has been called diff --git a/Tests/RunCMake/FetchContent/MakeAvailable.cmake b/Tests/RunCMake/FetchContent/MakeAvailable.cmake index a93f1f7..d7fc55c 100644 --- a/Tests/RunCMake/FetchContent/MakeAvailable.cmake +++ b/Tests/RunCMake/FetchContent/MakeAvailable.cmake @@ -8,13 +8,22 @@ FetchContent_Declare( WithoutProject SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/WithoutProject ) +FetchContent_Declare( + ProjectSubdir + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/WithoutProject + SOURCE_SUBDIR ProjectSubdir +) # Order is important and will be verified by test output -FetchContent_MakeAvailable(WithProject WithoutProject) +FetchContent_MakeAvailable(WithProject WithoutProject ProjectSubdir) get_property(addedWith GLOBAL PROPERTY FetchWithProject SET) if(NOT addedWith) - message(SEND_ERROR "Subdir with CMakeLists.txt not added") + message(SEND_ERROR "Project with top level CMakeLists.txt not added") +endif() +get_property(addedSubdir GLOBAL PROPERTY FetchWithSubProject SET) +if(NOT addedSubdir) + message(SEND_ERROR "Project with CMakeLists.txt in subdir not added") endif() include(${withoutproject_SOURCE_DIR}/confirmMessage.cmake) diff --git a/Tests/RunCMake/FetchContent/PreserveEmptyArgs-stdout.txt b/Tests/RunCMake/FetchContent/PreserveEmptyArgs-stdout.txt new file mode 100644 index 0000000..a72d914 --- /dev/null +++ b/Tests/RunCMake/FetchContent/PreserveEmptyArgs-stdout.txt @@ -0,0 +1,4 @@ +.*-- Number of arguments: 6 +.*-- Argument 3: 'before' +.*-- Argument 4: '' +.*-- Argument 5: 'after' diff --git a/Tests/RunCMake/FetchContent/PreserveEmptyArgs.cmake b/Tests/RunCMake/FetchContent/PreserveEmptyArgs.cmake new file mode 100644 index 0000000..4f35448 --- /dev/null +++ b/Tests/RunCMake/FetchContent/PreserveEmptyArgs.cmake @@ -0,0 +1,13 @@ +include(FetchContent) + +# Need to see the download command output +set(FETCHCONTENT_QUIET OFF) + +FetchContent_Declare( + t1 + DOWNLOAD_COMMAND ${CMAKE_COMMAND} -P + ${CMAKE_CURRENT_LIST_DIR}/countArgs.cmake + before "" after +) + +FetchContent_Populate(t1) diff --git a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake index e28ae96..f3ed3e2 100644 --- a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake +++ b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake @@ -6,6 +6,7 @@ run_cmake(MissingDetails) run_cmake(DirectIgnoresDetails) run_cmake(FirstDetailsWin) run_cmake(DownloadTwice) +run_cmake(DownloadFile) run_cmake(SameGenerator) run_cmake(VarDefinitions) run_cmake(GetProperties) @@ -15,6 +16,10 @@ run_cmake(MakeAvailable) run_cmake(MakeAvailableTwice) run_cmake(MakeAvailableUndeclared) +set(RunCMake_TEST_OUTPUT_MERGE 1) +run_cmake(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 diff --git a/Tests/RunCMake/FetchContent/WithoutProject/ProjectSubdir/CMakeLists.txt b/Tests/RunCMake/FetchContent/WithoutProject/ProjectSubdir/CMakeLists.txt new file mode 100644 index 0000000..216eeb1 --- /dev/null +++ b/Tests/RunCMake/FetchContent/WithoutProject/ProjectSubdir/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.13) +project(ProjectSubdir LANGUAGES NONE) + +set_property(GLOBAL PROPERTY FetchWithSubProject YES) +message(STATUS "Confirmation subproject has been added") diff --git a/Tests/RunCMake/FetchContent/countArgs.cmake b/Tests/RunCMake/FetchContent/countArgs.cmake new file mode 100644 index 0000000..7542af4 --- /dev/null +++ b/Tests/RunCMake/FetchContent/countArgs.cmake @@ -0,0 +1,5 @@ +message(STATUS "Number of arguments: ${CMAKE_ARGC}") +math(EXPR last "${CMAKE_ARGC} - 1") +foreach(n RANGE 3 ${last}) + message(STATUS "Argument ${n}: '${CMAKE_ARGV${n}}'") +endforeach() diff --git a/Tests/RunCMake/FetchContent/dummyFile.txt b/Tests/RunCMake/FetchContent/dummyFile.txt new file mode 100644 index 0000000..0a12ce1 --- /dev/null +++ b/Tests/RunCMake/FetchContent/dummyFile.txt @@ -0,0 +1 @@ +# This file is used to verify fetching a single file directly |