mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-23 14:48:19 -05:00
29e31e2825
Allow FetchContent_MakeAvailable() to try a call to find_package() first, or redirect a find_package() call to FetchContent_MakeAvailable(). The user can set variables to control which of these are allowed or tried by default. Fixes: #21687
16 lines
490 B
CMake
16 lines
490 B
CMake
include(FetchContent)
|
|
|
|
set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}/PackageConfigs)
|
|
|
|
FetchContent_Declare(
|
|
AddedProject
|
|
# Ensure failure if we don't re-route to find_package()
|
|
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/FatalIfAdded
|
|
FIND_PACKAGE_ARGS REQUIRED
|
|
)
|
|
|
|
# Cycle through a few calls to exercise global property changes
|
|
FetchContent_MakeAvailable(AddedProject)
|
|
find_package(AddedProject REQUIRED)
|
|
FetchContent_MakeAvailable(AddedProject) # Will re-route to find_package() again
|