summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2023-12-16 05:40:31 (GMT)
committerCraig Scott <craig.scott@crascit.com>2023-12-16 05:42:00 (GMT)
commit04153049700d82fd38b2a8388447e48fd6544e75 (patch)
tree7a561ee2c5d88ca40c379bd78f4a2ca8b07ce472
parent6ba3bb0563ca72fa6fa7bc705bdf38187e3fa485 (diff)
downloadCMake-04153049700d82fd38b2a8388447e48fd6544e75.zip
CMake-04153049700d82fd38b2a8388447e48fd6544e75.tar.gz
CMake-04153049700d82fd38b2a8388447e48fd6544e75.tar.bz2
FetchContent: Fix FIND_PACKAGE_ARGS not being passed to dep providers
Fixes: #25504
-rw-r--r--Modules/FetchContent.cmake4
-rw-r--r--Tests/RunCMake/DependencyProviders/ProviderFirst-stdout.txt6
-rw-r--r--Tests/RunCMake/DependencyProviders/ProviderFirst.cmake8
-rw-r--r--Tests/RunCMake/DependencyProviders/RunCMakeTest.cmake5
4 files changed, 21 insertions, 2 deletions
diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake
index 1038585..7293313 100644
--- a/Modules/FetchContent.cmake
+++ b/Modules/FetchContent.cmake
@@ -1975,12 +1975,12 @@ macro(FetchContent_MakeAvailable)
# This property might be defined but empty. As long as it is defined,
# find_package() can be called.
get_property(__cmake_addfpargs GLOBAL PROPERTY
- _FetchContent_${contentNameLower}_find_package_args
+ _FetchContent_${__cmake_contentNameLower}_find_package_args
DEFINED
)
if(__cmake_addfpargs)
get_property(__cmake_fpargs GLOBAL PROPERTY
- _FetchContent_${contentNameLower}_find_package_args
+ _FetchContent_${__cmake_contentNameLower}_find_package_args
)
string(APPEND __cmake_providerArgs " FIND_PACKAGE_ARGS")
foreach(__cmake_item IN LISTS __cmake_fpargs)
diff --git a/Tests/RunCMake/DependencyProviders/ProviderFirst-stdout.txt b/Tests/RunCMake/DependencyProviders/ProviderFirst-stdout.txt
new file mode 100644
index 0000000..53e554b
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/ProviderFirst-stdout.txt
@@ -0,0 +1,6 @@
+-- Before cmake_language
+-- After cmake_language
+-- Intercepted FetchContent_MakeAvailable\(SomeDep\)
+-- Provider invoked for method FETCHCONTENT_MAKEAVAILABLE_SERIAL with args: SOURCE_DIR;.*/Tests/RunCMake/DependencyProviders;BINARY_DIR;.*/Tests/RunCMake/DependencyProviders/ProviderFirst-build/_deps/somedep-build;EXTERNALPROJECT_INTERNAL_ARGUMENT_SEPARATOR;SOURCE_SUBDIR;DoesNotExist;FIND_PACKAGE_ARGS;QUIET;NO_DEFAULT_PATH;COMPONENTS;abc
+-- FetchContent_MakeAvailable\(\) succeeded
+-- Configuring done
diff --git a/Tests/RunCMake/DependencyProviders/ProviderFirst.cmake b/Tests/RunCMake/DependencyProviders/ProviderFirst.cmake
new file mode 100644
index 0000000..b27c841
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/ProviderFirst.cmake
@@ -0,0 +1,8 @@
+include(FetchContent)
+FetchContent_Declare(SomeDep
+ SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}
+ SOURCE_SUBDIR DoesNotExist
+ FIND_PACKAGE_ARGS NO_DEFAULT_PATH COMPONENTS abc
+)
+FetchContent_MakeAvailable(SomeDep)
+message(STATUS "FetchContent_MakeAvailable() succeeded")
diff --git a/Tests/RunCMake/DependencyProviders/RunCMakeTest.cmake b/Tests/RunCMake/DependencyProviders/RunCMakeTest.cmake
index 42893d2..300bbc1 100644
--- a/Tests/RunCMake/DependencyProviders/RunCMakeTest.cmake
+++ b/Tests/RunCMake/DependencyProviders/RunCMakeTest.cmake
@@ -61,6 +61,11 @@ run_cmake_with_options(RedirectFetchContentSerial
-D "provider_command=redirect_FetchContentSerial_provider"
-D "provider_methods=FETCHCONTENT_MAKEAVAILABLE_SERIAL"
)
+run_cmake_with_options(ProviderFirst
+ -D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=set_provider.cmake"
+ -D "provider_command=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"