diff options
author | Craig Scott <craig.scott@crascit.com> | 2019-01-20 08:53:27 (GMT) |
---|---|---|
committer | Craig Scott <craig.scott@crascit.com> | 2019-01-26 05:49:15 (GMT) |
commit | a94355c7b781378f73b70010ee97f9d5d6209e68 (patch) | |
tree | c2898dac198110027e97fe2a75fab12538e4c204 /Tests/RunCMake | |
parent | 611d5274de677a42bdf744c48f0e4a29ea1bb1cd (diff) | |
download | CMake-a94355c7b781378f73b70010ee97f9d5d6209e68.zip CMake-a94355c7b781378f73b70010ee97f9d5d6209e68.tar.gz CMake-a94355c7b781378f73b70010ee97f9d5d6209e68.tar.bz2 |
FetchContent: Add new command FetchContent_MakeAvailable()
Relates: #18754
Diffstat (limited to 'Tests/RunCMake')
10 files changed, 52 insertions, 0 deletions
diff --git a/Tests/RunCMake/FetchContent/MakeAvailable-stdout.txt b/Tests/RunCMake/FetchContent/MakeAvailable-stdout.txt new file mode 100644 index 0000000..6e6c730 --- /dev/null +++ b/Tests/RunCMake/FetchContent/MakeAvailable-stdout.txt @@ -0,0 +1,2 @@ +Confirmation project has been added +.*Confirmation script has been called diff --git a/Tests/RunCMake/FetchContent/MakeAvailable.cmake b/Tests/RunCMake/FetchContent/MakeAvailable.cmake new file mode 100644 index 0000000..a93f1f7 --- /dev/null +++ b/Tests/RunCMake/FetchContent/MakeAvailable.cmake @@ -0,0 +1,20 @@ +include(FetchContent) + +FetchContent_Declare( + WithProject + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/WithProject +) +FetchContent_Declare( + WithoutProject + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/WithoutProject +) + +# Order is important and will be verified by test output +FetchContent_MakeAvailable(WithProject WithoutProject) + +get_property(addedWith GLOBAL PROPERTY FetchWithProject SET) +if(NOT addedWith) + message(SEND_ERROR "Subdir with CMakeLists.txt not added") +endif() + +include(${withoutproject_SOURCE_DIR}/confirmMessage.cmake) diff --git a/Tests/RunCMake/FetchContent/MakeAvailableTwice-stdout.txt b/Tests/RunCMake/FetchContent/MakeAvailableTwice-stdout.txt new file mode 100644 index 0000000..8d3b7c0 --- /dev/null +++ b/Tests/RunCMake/FetchContent/MakeAvailableTwice-stdout.txt @@ -0,0 +1,4 @@ +-- Before first[ + ]+-- Confirmation project has been added[ + ]+-- Between both[ + ]+-- After last diff --git a/Tests/RunCMake/FetchContent/MakeAvailableTwice.cmake b/Tests/RunCMake/FetchContent/MakeAvailableTwice.cmake new file mode 100644 index 0000000..a9af020 --- /dev/null +++ b/Tests/RunCMake/FetchContent/MakeAvailableTwice.cmake @@ -0,0 +1,12 @@ +include(FetchContent) + +FetchContent_Declare( + WithProject + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/WithProject +) + +message(STATUS "Before first") +FetchContent_MakeAvailable(WithProject) +message(STATUS "Between both") +FetchContent_MakeAvailable(WithProject) +message(STATUS "After last") diff --git a/Tests/RunCMake/FetchContent/MakeAvailableUndeclared-result.txt b/Tests/RunCMake/FetchContent/MakeAvailableUndeclared-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FetchContent/MakeAvailableUndeclared-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FetchContent/MakeAvailableUndeclared-stderr.txt b/Tests/RunCMake/FetchContent/MakeAvailableUndeclared-stderr.txt new file mode 100644 index 0000000..9715b78 --- /dev/null +++ b/Tests/RunCMake/FetchContent/MakeAvailableUndeclared-stderr.txt @@ -0,0 +1 @@ +No content details recorded for NoDetails diff --git a/Tests/RunCMake/FetchContent/MakeAvailableUndeclared.cmake b/Tests/RunCMake/FetchContent/MakeAvailableUndeclared.cmake new file mode 100644 index 0000000..bd57cbe --- /dev/null +++ b/Tests/RunCMake/FetchContent/MakeAvailableUndeclared.cmake @@ -0,0 +1,3 @@ +include(FetchContent) + +FetchContent_MakeAvailable(NoDetails) diff --git a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake index 9c1ab66..e28ae96 100644 --- a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake +++ b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake @@ -11,6 +11,9 @@ run_cmake(VarDefinitions) run_cmake(GetProperties) run_cmake(DirOverrides) run_cmake(UsesTerminalOverride) +run_cmake(MakeAvailable) +run_cmake(MakeAvailableTwice) +run_cmake(MakeAvailableUndeclared) # We need to pass through CMAKE_GENERATOR and CMAKE_MAKE_PROGRAM # to ensure the test can run on machines where the build tool diff --git a/Tests/RunCMake/FetchContent/WithProject/CMakeLists.txt b/Tests/RunCMake/FetchContent/WithProject/CMakeLists.txt new file mode 100644 index 0000000..b6a3750 --- /dev/null +++ b/Tests/RunCMake/FetchContent/WithProject/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.13) +project(WithProject LANGUAGES NONE) + +set_property(GLOBAL PROPERTY FetchWithProject YES) +message(STATUS "Confirmation project has been added") diff --git a/Tests/RunCMake/FetchContent/WithoutProject/confirmMessage.cmake b/Tests/RunCMake/FetchContent/WithoutProject/confirmMessage.cmake new file mode 100644 index 0000000..a2f5c61 --- /dev/null +++ b/Tests/RunCMake/FetchContent/WithoutProject/confirmMessage.cmake @@ -0,0 +1 @@ +message(STATUS "Confirmation script has been called") |