cmake/Tests/RunCMake/FetchContent_find_package/Try_find_package-ALWAYS.cmake

19 lines
500 B
CMake
Raw Normal View History

2022-08-04 22:12:04 +02:00
include(FetchContent)
set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}/PackageConfigs)
set(FETCHCONTENT_TRY_FIND_PACKAGE_MODE ALWAYS)
FetchContent_Declare(
FirstProject
# Ensure failure if we don't re-route to find_package()
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/FatalIfAdded
)
FetchContent_Declare(
SecondProject
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/AddedProject
OVERRIDE_FIND_PACKAGE # Takes precedence over ALWAYS mode
)
FetchContent_MakeAvailable(FirstProject SecondProject)