Commit a94355c7 authored by Craig Scott's avatar Craig Scott

FetchContent: Add new command FetchContent_MakeAvailable()

Relates: #18754
parent 611d5274
fetchcontent-reduce-boilerplate
-------------------------------
* The FetchContent module gained a new :command:`FetchContent_MakeAvailable`
command. This new command accepts a list of dependency names, which it then
iterates over, populating and adding each one to the main build using the
canonical pattern. This significantly reduces the amount of boilerplate
needed in the project.
This diff is collapsed.
Confirmation project has been added
.*Confirmation script has been called
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)
-- Before first[
]+-- Confirmation project has been added[
]+-- Between both[
]+-- After last
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")
include(FetchContent)
FetchContent_MakeAvailable(NoDetails)
......@@ -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
......
cmake_minimum_required(VERSION 3.13)
project(WithProject LANGUAGES NONE)
set_property(GLOBAL PROPERTY FetchWithProject YES)
message(STATUS "Confirmation project has been added")
message(STATUS "Confirmation script has been called")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment