浏览代码

Merge topic 'fc-provider-find-package-args'

0415304970 FetchContent: Fix FIND_PACKAGE_ARGS not being passed to dep providers

Acked-by: Kitware Robot <[email protected]>
Merge-request: !9080
Craig Scott 1 年之前
父节点
当前提交
50e8791f92

+ 2 - 2
Modules/FetchContent.cmake

@@ -1986,12 +1986,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)

+ 6 - 0
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

+ 8 - 0
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")

+ 5 - 0
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"