diff options
Diffstat (limited to 'Tests')
38 files changed, 286 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 4fe6ac1..da91e64 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -461,6 +461,7 @@ add_RunCMake_test(message) add_RunCMake_test(option) add_RunCMake_test(project -DCMake_TEST_RESOURCES=${CMake_TEST_RESOURCES}) add_RunCMake_test(project_injected) +add_RunCMake_test(DependencyProviders) add_RunCMake_test(return) add_RunCMake_test(separate_arguments) add_RunCMake_test(set_property) diff --git a/Tests/RunCMake/DependencyProviders/AfterProject-result.txt b/Tests/RunCMake/DependencyProviders/AfterProject-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/AfterProject-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/DependencyProviders/AfterProject-stderr.txt b/Tests/RunCMake/DependencyProviders/AfterProject-stderr.txt new file mode 100644 index 0000000..7bee23c --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/AfterProject-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at set_provider\.cmake:[0-9]+ \(cmake_language\): + cmake_language Dependency providers can only be set as part of the first + call to project\(\)\. More specifically, + cmake_language\(SET_DEPENDENCY_PROVIDER\) can only be called while the first + project\(\) command processes files listed in + CMAKE_PROJECT_TOP_LEVEL_INCLUDES\. diff --git a/Tests/RunCMake/DependencyProviders/BeforeProject-result.txt b/Tests/RunCMake/DependencyProviders/BeforeProject-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/BeforeProject-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/DependencyProviders/BeforeProject-stderr.txt b/Tests/RunCMake/DependencyProviders/BeforeProject-stderr.txt new file mode 100644 index 0000000..7bee23c --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/BeforeProject-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at set_provider\.cmake:[0-9]+ \(cmake_language\): + cmake_language Dependency providers can only be set as part of the first + call to project\(\)\. More specifically, + cmake_language\(SET_DEPENDENCY_PROVIDER\) can only be called while the first + project\(\) command processes files listed in + CMAKE_PROJECT_TOP_LEVEL_INCLUDES\. diff --git a/Tests/RunCMake/DependencyProviders/Bypass-stdout.txt b/Tests/RunCMake/DependencyProviders/Bypass-stdout.txt new file mode 100644 index 0000000..b0c7e6e --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/Bypass-stdout.txt @@ -0,0 +1,7 @@ +-- Before cmake_language +-- After cmake_language +-- Forwarding find_package\(SomeDep\) +-- Provider invoked for method FIND_PACKAGE with args: QUIET;REQUIRED +-- SomeDepConfig\.cmake was used +-- Leaving provider +-- Configuring done diff --git a/Tests/RunCMake/DependencyProviders/Bypass.cmake b/Tests/RunCMake/DependencyProviders/Bypass.cmake new file mode 100644 index 0000000..883087e --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/Bypass.cmake @@ -0,0 +1 @@ +find_package(SomeDep QUIET REQUIRED) diff --git a/Tests/RunCMake/DependencyProviders/CMakeLists.txt b/Tests/RunCMake/DependencyProviders/CMakeLists.txt new file mode 100644 index 0000000..3552604 --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.23...3.24) + +if(DEFINED include_before_project) + include("${include_before_project}") +endif() + +project(${RunCMake_TEST} NONE) + +if(DEFINED include_after_project) + include("${include_after_project}") +endif() + +include(${RunCMake_TEST}.cmake OPTIONAL) diff --git a/Tests/RunCMake/DependencyProviders/ConfigFiles/SomeDepConfig.cmake b/Tests/RunCMake/DependencyProviders/ConfigFiles/SomeDepConfig.cmake new file mode 100644 index 0000000..e04eefe --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/ConfigFiles/SomeDepConfig.cmake @@ -0,0 +1,2 @@ +message(STATUS "SomeDepConfig.cmake was used") +set(SomeDep_FOUND TRUE) diff --git a/Tests/RunCMake/DependencyProviders/FetchContentSerial-stdout.txt b/Tests/RunCMake/DependencyProviders/FetchContentSerial-stdout.txt new file mode 100644 index 0000000..fa4a794 --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/FetchContentSerial-stdout.txt @@ -0,0 +1,7 @@ +-- Before cmake_language +-- After cmake_language +-- AThing_FOUND = 0 +-- Intercepted FetchContent_MakeAvailable\(SomeDep\) +-- Provider invoked for method FETCHCONTENT_MAKEAVAILABLE_SERIAL with args: SOURCE_DIR;.*/Tests/RunCMake/DependencyProviders;BINARY_DIR;.*/Tests/RunCMake/DependencyProviders/FetchContentSerial-build/_deps/somedep-build;SOURCE_SUBDIR;DoesNotExist +-- FetchContent_MakeAvailable\(\) succeeded +-- Configuring done diff --git a/Tests/RunCMake/DependencyProviders/FetchContentSerial.cmake b/Tests/RunCMake/DependencyProviders/FetchContentSerial.cmake new file mode 100644 index 0000000..cbd3010 --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/FetchContentSerial.cmake @@ -0,0 +1 @@ +include(try_methods.cmake) diff --git a/Tests/RunCMake/DependencyProviders/FindPackage-stdout.txt b/Tests/RunCMake/DependencyProviders/FindPackage-stdout.txt new file mode 100644 index 0000000..19c88b9 --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/FindPackage-stdout.txt @@ -0,0 +1,7 @@ +-- Before cmake_language +-- After cmake_language +-- Intercepted find_package\(AThing\) +-- Provider invoked for method FIND_PACKAGE with args: QUIET +-- AThing_FOUND = TRUE +-- FetchContent_MakeAvailable\(\) succeeded +-- Configuring done diff --git a/Tests/RunCMake/DependencyProviders/FindPackage.cmake b/Tests/RunCMake/DependencyProviders/FindPackage.cmake new file mode 100644 index 0000000..cbd3010 --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/FindPackage.cmake @@ -0,0 +1 @@ +include(try_methods.cmake) diff --git a/Tests/RunCMake/DependencyProviders/NoCommand-result.txt b/Tests/RunCMake/DependencyProviders/NoCommand-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/NoCommand-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/DependencyProviders/NoCommand-stderr.txt b/Tests/RunCMake/DependencyProviders/NoCommand-stderr.txt new file mode 100644 index 0000000..a43222f --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/NoCommand-stderr.txt @@ -0,0 +1,3 @@ +CMake Error at set_provider\.cmake:[0-9]+ \(cmake_language\): + cmake_language Must specify a non-empty command name when provider methods + are given diff --git a/Tests/RunCMake/DependencyProviders/NoCommandOrMethods-stdout.txt b/Tests/RunCMake/DependencyProviders/NoCommandOrMethods-stdout.txt new file mode 100644 index 0000000..c53435b --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/NoCommandOrMethods-stdout.txt @@ -0,0 +1,3 @@ +-- Before cmake_language +-- After cmake_language +-- AThing_FOUND = 0 diff --git a/Tests/RunCMake/DependencyProviders/NoCommandOrMethods.cmake b/Tests/RunCMake/DependencyProviders/NoCommandOrMethods.cmake new file mode 100644 index 0000000..bde0cf8 --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/NoCommandOrMethods.cmake @@ -0,0 +1,3 @@ +# Force the provider to be invoked +find_package(AThing QUIET) +message(STATUS "AThing_FOUND = ${AThing_FOUND}") diff --git a/Tests/RunCMake/DependencyProviders/NoMethods-result.txt b/Tests/RunCMake/DependencyProviders/NoMethods-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/NoMethods-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/DependencyProviders/NoMethods-stderr.txt b/Tests/RunCMake/DependencyProviders/NoMethods-stderr.txt new file mode 100644 index 0000000..6968851 --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/NoMethods-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at set_provider\.cmake:[0-9]+ \(cmake_language\): + cmake_language Must specify at least one provider method diff --git a/Tests/RunCMake/DependencyProviders/PassThroughProvider-stdout.txt b/Tests/RunCMake/DependencyProviders/PassThroughProvider-stdout.txt new file mode 100644 index 0000000..0c9303a --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/PassThroughProvider-stdout.txt @@ -0,0 +1,7 @@ +-- Before cmake_language +-- After cmake_language +-- Null provider called +-- Provider invoked for method FIND_PACKAGE with args: AThing;QUIET +-- AThing_FOUND = 0 +-- Null provider called +-- Provider invoked for method FETCHCONTENT_MAKEAVAILABLE_SERIAL with args: SomeDep;SOURCE_DIR;.*/Tests/RunCMake/DependencyProviders;BINARY_DIR;.*/Tests/RunCMake/DependencyProviders/PassThroughProvider-build/_deps/somedep-build;SOURCE_SUBDIR;DoesNotExist diff --git a/Tests/RunCMake/DependencyProviders/PassThroughProvider.cmake b/Tests/RunCMake/DependencyProviders/PassThroughProvider.cmake new file mode 100644 index 0000000..cbd3010 --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/PassThroughProvider.cmake @@ -0,0 +1 @@ +include(try_methods.cmake) diff --git a/Tests/RunCMake/DependencyProviders/ProjectIncludeAfter-result.txt b/Tests/RunCMake/DependencyProviders/ProjectIncludeAfter-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/ProjectIncludeAfter-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/DependencyProviders/ProjectIncludeAfter-stderr.txt b/Tests/RunCMake/DependencyProviders/ProjectIncludeAfter-stderr.txt new file mode 100644 index 0000000..7bee23c --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/ProjectIncludeAfter-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at set_provider\.cmake:[0-9]+ \(cmake_language\): + cmake_language Dependency providers can only be set as part of the first + call to project\(\)\. More specifically, + cmake_language\(SET_DEPENDENCY_PROVIDER\) can only be called while the first + project\(\) command processes files listed in + CMAKE_PROJECT_TOP_LEVEL_INCLUDES\. diff --git a/Tests/RunCMake/DependencyProviders/ProjectIncludeBefore-result.txt b/Tests/RunCMake/DependencyProviders/ProjectIncludeBefore-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/ProjectIncludeBefore-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/DependencyProviders/ProjectIncludeBefore-stderr.txt b/Tests/RunCMake/DependencyProviders/ProjectIncludeBefore-stderr.txt new file mode 100644 index 0000000..7bee23c --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/ProjectIncludeBefore-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at set_provider\.cmake:[0-9]+ \(cmake_language\): + cmake_language Dependency providers can only be set as part of the first + call to project\(\)\. More specifically, + cmake_language\(SET_DEPENDENCY_PROVIDER\) can only be called while the first + project\(\) command processes files listed in + CMAKE_PROJECT_TOP_LEVEL_INCLUDES\. diff --git a/Tests/RunCMake/DependencyProviders/Recurse-stdout.txt b/Tests/RunCMake/DependencyProviders/Recurse-stdout.txt new file mode 100644 index 0000000..2c2035a --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/Recurse-stdout.txt @@ -0,0 +1,7 @@ +-- Before cmake_language +-- After cmake_language +-- Intercepted FetchContent_MakeAvailable\(SomeDep\) +-- Provider invoked for method FETCHCONTENT_MAKEAVAILABLE_SERIAL with args: SOURCE_DIR;.*/Tests/RunCMake/DependencyProviders/Recurse-build/_deps/somedep-src;BINARY_DIR;.*/Tests/RunCMake/DependencyProviders/Recurse-build/_deps/somedep-build;DOWNLOAD_COMMAND;.*/cmake(\.exe)?;-E;echo;Download command called +.*Download command called +.*-- Should now be handled +-- Configuring done diff --git a/Tests/RunCMake/DependencyProviders/Recurse.cmake b/Tests/RunCMake/DependencyProviders/Recurse.cmake new file mode 100644 index 0000000..3a79d9c --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/Recurse.cmake @@ -0,0 +1,8 @@ +include(FetchContent) + +set(FETCHCONTENT_QUIET NO) + +FetchContent_Declare(SomeDep + DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E echo "Download command called" +) +FetchContent_MakeAvailable(SomeDep) diff --git a/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial-result.txt b/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial-stderr.txt b/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial-stderr.txt new file mode 100644 index 0000000..047a64b --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at set_provider\.cmake:[0-9]+ \(find_package\): + Could not find a package configuration file provided by "SomeDep" with any + of the following names: + + SomeDepConfig\.cmake + somedep-config\.cmake + + Add the installation prefix of "SomeDep" to CMAKE_PREFIX_PATH or set + "SomeDep_DIR" to a directory containing one of the above files\. If + "SomeDep" provides a separate development package or SDK, be sure it has + been installed\. diff --git a/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial-stdout.txt b/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial-stdout.txt new file mode 100644 index 0000000..a293324 --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial-stdout.txt @@ -0,0 +1,5 @@ +-- Before cmake_language +-- After cmake_language +-- AThing_FOUND = 0 +-- Redirecting FetchContent_MakeAvailable\(SomeDep\) to find_package\(\) +-- Provider invoked for method FETCHCONTENT_MAKEAVAILABLE_SERIAL with args: SOURCE_DIR;.*/Tests/RunCMake/DependencyProviders;BINARY_DIR;.*/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial-build/_deps/somedep-build;SOURCE_SUBDIR;DoesNotExist diff --git a/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial.cmake b/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial.cmake new file mode 100644 index 0000000..cbd3010 --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial.cmake @@ -0,0 +1 @@ +include(try_methods.cmake) diff --git a/Tests/RunCMake/DependencyProviders/RedirectFindPackage-stdout.txt b/Tests/RunCMake/DependencyProviders/RedirectFindPackage-stdout.txt new file mode 100644 index 0000000..23e751d --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/RedirectFindPackage-stdout.txt @@ -0,0 +1,7 @@ +-- Before cmake_language +-- After cmake_language +-- Redirecting find_package\(AThing\) to FetchContent_MakeAvailable\(\) +-- Provider invoked for method FIND_PACKAGE with args: QUIET +-- AThing_FOUND = TRUE +-- FetchContent_MakeAvailable\(\) succeeded +-- Configuring done diff --git a/Tests/RunCMake/DependencyProviders/RedirectFindPackage.cmake b/Tests/RunCMake/DependencyProviders/RedirectFindPackage.cmake new file mode 100644 index 0000000..cbd3010 --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/RedirectFindPackage.cmake @@ -0,0 +1 @@ +include(try_methods.cmake) diff --git a/Tests/RunCMake/DependencyProviders/RunCMakeTest.cmake b/Tests/RunCMake/DependencyProviders/RunCMakeTest.cmake new file mode 100644 index 0000000..42893d2 --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/RunCMakeTest.cmake @@ -0,0 +1,73 @@ +include(RunCMake) + +run_cmake_with_options(BeforeProject + -D "include_before_project=set_provider.cmake" + -D "provider_command=null_provider" + -D "provider_methods=find_package" +) +run_cmake_with_options(AfterProject + -D "include_after_project=set_provider.cmake" + -D "provider_command=null_provider" + -D "provider_methods=find_package" +) +run_cmake_with_options(ProjectIncludeBefore + -D "CMAKE_PROJECT_INCLUDE_BEFORE=set_provider.cmake" + -D "provider_command=null_provider" + -D "provider_methods=find_package" +) +run_cmake_with_options(ProjectIncludeAfter + -D "CMAKE_PROJECT_INCLUDE=set_provider.cmake" + -D "provider_command=null_provider" + -D "provider_methods=find_package" +) +run_cmake_with_options(ToolchainFile + -D "CMAKE_TOOLCHAIN_FILE=set_provider.cmake" + -D "provider_command=null_provider" + -D "provider_methods=find_package" +) +run_cmake_with_options(NoCommand + -D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=set_provider.cmake" + -D "provider_methods=find_package" +) +run_cmake_with_options(NoMethods + -D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=set_provider.cmake" + -D "provider_command=null_provider" +) +run_cmake_with_options(NoCommandOrMethods + -D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=set_provider.cmake" +) +run_cmake_with_options(PassThroughProvider + -D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=set_provider.cmake" + -D "provider_command=null_provider" + -D "provider_methods=FIND_PACKAGE\\;FETCHCONTENT_MAKEAVAILABLE_SERIAL" +) +run_cmake_with_options(FindPackage + -D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=set_provider.cmake" + -D "provider_command=find_package_provider" + -D "provider_methods=FIND_PACKAGE" +) +run_cmake_with_options(RedirectFindPackage + -D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=set_provider.cmake" + -D "provider_command=redirect_find_package_provider" + -D "provider_methods=FIND_PACKAGE" +) +run_cmake_with_options(FetchContentSerial + -D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=set_provider.cmake" + -D "provider_command=FetchContentSerial_provider" + -D "provider_methods=FETCHCONTENT_MAKEAVAILABLE_SERIAL" +) +run_cmake_with_options(RedirectFetchContentSerial + -D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=set_provider.cmake" + -D "provider_command=redirect_FetchContentSerial_provider" + -D "provider_methods=FETCHCONTENT_MAKEAVAILABLE_SERIAL" +) +run_cmake_with_options(Bypass + -D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=set_provider.cmake" + -D "provider_command=forward_find_package" + -D "provider_methods=FIND_PACKAGE" +) +run_cmake_with_options(Recurse + -D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=set_provider.cmake" + -D "provider_command=recurse_FetchContent" + -D "provider_methods=FETCHCONTENT_MAKEAVAILABLE_SERIAL" +) diff --git a/Tests/RunCMake/DependencyProviders/ToolchainFile-result.txt b/Tests/RunCMake/DependencyProviders/ToolchainFile-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/ToolchainFile-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/DependencyProviders/ToolchainFile-stderr.txt b/Tests/RunCMake/DependencyProviders/ToolchainFile-stderr.txt new file mode 100644 index 0000000..7bee23c --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/ToolchainFile-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at set_provider\.cmake:[0-9]+ \(cmake_language\): + cmake_language Dependency providers can only be set as part of the first + call to project\(\)\. More specifically, + cmake_language\(SET_DEPENDENCY_PROVIDER\) can only be called while the first + project\(\) command processes files listed in + CMAKE_PROJECT_TOP_LEVEL_INCLUDES\. diff --git a/Tests/RunCMake/DependencyProviders/set_provider.cmake b/Tests/RunCMake/DependencyProviders/set_provider.cmake new file mode 100644 index 0000000..6e82b8f --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/set_provider.cmake @@ -0,0 +1,64 @@ +include(FetchContent) + +macro(null_provider method) + message(STATUS "Null provider called") + message(STATUS "Provider invoked for method ${method} with args: ${ARGN}") +endmacro() + +macro(find_package_provider method package_name) + message(STATUS "Intercepted find_package(${package_name})") + message(STATUS "Provider invoked for method ${method} with args: ${ARGN}") + set(${package_name}_FOUND TRUE) +endmacro() + +macro(FetchContentSerial_provider method dep_name) + message(STATUS "Intercepted FetchContent_MakeAvailable(${dep_name})") + message(STATUS "Provider invoked for method ${method} with args: ${ARGN}") + FetchContent_SetPopulated(${dep_name}) +endmacro() + +macro(redirect_find_package_provider method package_name) + message(STATUS "Redirecting find_package(${package_name}) to FetchContent_MakeAvailable()") + message(STATUS "Provider invoked for method ${method} with args: ${ARGN}") + FetchContent_Declare(${package_name} + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR} + SOURCE_SUBDIR DoesNotExist + ) + FetchContent_MakeAvailable(${package_name}) + set(${package_name}_FOUND TRUE) +endmacro() + +macro(redirect_FetchContentSerial_provider method dep_name) + message(STATUS "Redirecting FetchContent_MakeAvailable(${dep_name}) to find_package()") + message(STATUS "Provider invoked for method ${method} with args: ${ARGN}") + find_package(${dep_name} NO_DEFAULT_PATH + PATHS ${CMAKE_CURRENT_LIST_DIR}/Finders + REQUIRED + ) + FetchContent_SetPopulated(${dep_name}) +endmacro() + +macro(forward_find_package method package_name) + message(STATUS "Forwarding find_package(${package_name})") + message(STATUS "Provider invoked for method ${method} with args: ${ARGN}") + find_package(${package_name} + BYPASS_PROVIDER + PATHS ${CMAKE_CURRENT_LIST_DIR}/ConfigFiles + ${ARGN} + ) + message(STATUS "Leaving provider") +endmacro() + +macro(recurse_FetchContent method dep_name) + message(STATUS "Intercepted FetchContent_MakeAvailable(${dep_name})") + message(STATUS "Provider invoked for method ${method} with args: ${ARGN}") + FetchContent_MakeAvailable(${dep_name}) + message(STATUS "Should now be handled") +endmacro() + +message(STATUS "Before cmake_language") +cmake_language( + SET_DEPENDENCY_PROVIDER ${provider_command} + SUPPORTED_METHODS ${provider_methods} +) +message(STATUS "After cmake_language") diff --git a/Tests/RunCMake/DependencyProviders/try_methods.cmake b/Tests/RunCMake/DependencyProviders/try_methods.cmake new file mode 100644 index 0000000..652c32d --- /dev/null +++ b/Tests/RunCMake/DependencyProviders/try_methods.cmake @@ -0,0 +1,12 @@ +# Force the provider to be invoked for each method +find_package(AThing QUIET) +message(STATUS "AThing_FOUND = ${AThing_FOUND}") + +# These declared details should always succeed when used +include(FetchContent) +FetchContent_Declare(SomeDep + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR} + SOURCE_SUBDIR DoesNotExist +) +FetchContent_MakeAvailable(SomeDep) +message(STATUS "FetchContent_MakeAvailable() succeeded") |