From ab358d6a859d8b7e257ed1e06ca000e097a32ef6 Mon Sep 17 00:00:00 2001 From: Matthew Woehlke Date: Mon, 22 May 2017 13:32:43 -0400 Subject: Improve find_dependency argument handling Remove highly specialized and totally positional argument handling in find_dependency macro, and instead just pass arguments through to find_package. This gives users access to the full suite of arguments that find_package knows, and is backward compatible with the old arguments. Also, rewrite the unit tests for this, since the old tests are exclusively focused on testing the old argument handling and are no longer applicable, and add some success tests (the old tests did not even set up the CMake state in a way that CMake had any hope of ever finding the test package). --- Modules/CMakeFindDependencyMacro.cmake | 38 +++++----------------- Tests/RunCMake/find_dependency/CMakeLists.txt | 1 - .../find_dependency/EXACT-no-version-result.txt | 1 - .../find_dependency/EXACT-no-version-stderr.txt | 6 ---- .../find_dependency/EXACT-no-version.cmake | 4 --- .../find_dependency/Pack1/Pack1Config.cmake | 2 -- .../find_dependency/Pack1/Pack1ConfigVersion.cmake | 11 ------- Tests/RunCMake/find_dependency/RunCMakeTest.cmake | 13 +++++--- .../find_dependency/bad-version-exact-result.txt | 1 + .../find_dependency/bad-version-exact-stderr.txt | 11 +++++++ .../find_dependency/bad-version-exact.cmake | 5 +++ .../find_dependency/bad-version-fuzzy-result.txt | 1 + .../find_dependency/bad-version-fuzzy-stderr.txt | 11 +++++++ .../find_dependency/bad-version-fuzzy.cmake | 5 +++ Tests/RunCMake/find_dependency/basic.cmake | 5 +++ .../find_dependency/empty-arg-3-result.txt | 1 - .../find_dependency/empty-arg-3-stderr.txt | 5 --- Tests/RunCMake/find_dependency/empty-arg-3.cmake | 4 --- .../find_dependency/empty-version-result.txt | 1 - .../find_dependency/empty-version-stderr.txt | 5 --- Tests/RunCMake/find_dependency/empty-version.cmake | 4 --- .../RunCMake/find_dependency/extra-args-result.txt | 1 - .../RunCMake/find_dependency/extra-args-stderr.txt | 5 --- Tests/RunCMake/find_dependency/extra-args.cmake | 4 --- .../find_dependency/invalid-arg-3-result.txt | 1 - .../find_dependency/invalid-arg-3-stderr.txt | 5 --- Tests/RunCMake/find_dependency/invalid-arg-3.cmake | 4 --- .../find_dependency/invalid-arg-result.txt | 1 + .../find_dependency/invalid-arg-stderr.txt | 5 +++ Tests/RunCMake/find_dependency/invalid-arg.cmake | 5 +++ Tests/RunCMake/find_dependency/realistic.cmake | 3 ++ .../share/cmake/Pack1/Pack1Config.cmake | 2 ++ .../share/cmake/Pack1/Pack1ConfigVersion.cmake | 11 +++++++ .../share/cmake/Pack2/Pack2Config.cmake | 6 ++++ .../share/cmake/Pack2/Pack2ConfigVersion.cmake | 11 +++++++ 35 files changed, 100 insertions(+), 99 deletions(-) delete mode 100644 Tests/RunCMake/find_dependency/EXACT-no-version-result.txt delete mode 100644 Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt delete mode 100644 Tests/RunCMake/find_dependency/EXACT-no-version.cmake delete mode 100644 Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake delete mode 100644 Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake create mode 100644 Tests/RunCMake/find_dependency/bad-version-exact-result.txt create mode 100644 Tests/RunCMake/find_dependency/bad-version-exact-stderr.txt create mode 100644 Tests/RunCMake/find_dependency/bad-version-exact.cmake create mode 100644 Tests/RunCMake/find_dependency/bad-version-fuzzy-result.txt create mode 100644 Tests/RunCMake/find_dependency/bad-version-fuzzy-stderr.txt create mode 100644 Tests/RunCMake/find_dependency/bad-version-fuzzy.cmake create mode 100644 Tests/RunCMake/find_dependency/basic.cmake delete mode 100644 Tests/RunCMake/find_dependency/empty-arg-3-result.txt delete mode 100644 Tests/RunCMake/find_dependency/empty-arg-3-stderr.txt delete mode 100644 Tests/RunCMake/find_dependency/empty-arg-3.cmake delete mode 100644 Tests/RunCMake/find_dependency/empty-version-result.txt delete mode 100644 Tests/RunCMake/find_dependency/empty-version-stderr.txt delete mode 100644 Tests/RunCMake/find_dependency/empty-version.cmake delete mode 100644 Tests/RunCMake/find_dependency/extra-args-result.txt delete mode 100644 Tests/RunCMake/find_dependency/extra-args-stderr.txt delete mode 100644 Tests/RunCMake/find_dependency/extra-args.cmake delete mode 100644 Tests/RunCMake/find_dependency/invalid-arg-3-result.txt delete mode 100644 Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt delete mode 100644 Tests/RunCMake/find_dependency/invalid-arg-3.cmake create mode 100644 Tests/RunCMake/find_dependency/invalid-arg-result.txt create mode 100644 Tests/RunCMake/find_dependency/invalid-arg-stderr.txt create mode 100644 Tests/RunCMake/find_dependency/invalid-arg.cmake create mode 100644 Tests/RunCMake/find_dependency/realistic.cmake create mode 100644 Tests/RunCMake/find_dependency/share/cmake/Pack1/Pack1Config.cmake create mode 100644 Tests/RunCMake/find_dependency/share/cmake/Pack1/Pack1ConfigVersion.cmake create mode 100644 Tests/RunCMake/find_dependency/share/cmake/Pack2/Pack2Config.cmake create mode 100644 Tests/RunCMake/find_dependency/share/cmake/Pack2/Pack2ConfigVersion.cmake diff --git a/Modules/CMakeFindDependencyMacro.cmake b/Modules/CMakeFindDependencyMacro.cmake index 61f74ef..81606ce 100644 --- a/Modules/CMakeFindDependencyMacro.cmake +++ b/Modules/CMakeFindDependencyMacro.cmake @@ -7,38 +7,20 @@ # # :: # -# find_dependency( [ [EXACT]]) +# find_dependency( [...]) # # # ``find_dependency()`` wraps a :command:`find_package` call for a package # dependency. It is designed to be used in a Config.cmake file, and it -# forwards the correct parameters for EXACT, QUIET and REQUIRED which were -# passed to the original :command:`find_package` call. It also sets an -# informative diagnostic message if the dependency could not be found. +# forwards the correct parameters for QUIET and REQUIRED which were passed to +# the original :command:`find_package` call. It also sets an informative +# diagnostic message if the dependency could not be found. +# +# Any additional arguments specified are forwarded to :command:`find_package`. # macro(find_dependency dep) if (NOT ${dep}_FOUND) - set(cmake_fd_version) - if (${ARGC} GREATER 1) - if ("${ARGV1}" STREQUAL "") - message(FATAL_ERROR "Invalid arguments to find_dependency. VERSION is empty") - endif() - if ("${ARGV1}" STREQUAL EXACT) - message(FATAL_ERROR "Invalid arguments to find_dependency. EXACT may only be specified if a VERSION is specified") - endif() - set(cmake_fd_version ${ARGV1}) - endif() - set(cmake_fd_exact_arg) - if(${ARGC} GREATER 2) - if (NOT "${ARGV2}" STREQUAL EXACT) - message(FATAL_ERROR "Invalid arguments to find_dependency") - endif() - set(cmake_fd_exact_arg EXACT) - endif() - if(${ARGC} GREATER 3) - message(FATAL_ERROR "Invalid arguments to find_dependency") - endif() set(cmake_fd_quiet_arg) if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) set(cmake_fd_quiet_arg QUIET) @@ -52,10 +34,9 @@ macro(find_dependency dep) _CMAKE_${dep}_TRANSITIVE_DEPENDENCY ) - find_package(${dep} ${cmake_fd_version} - ${cmake_fd_exact_arg} - ${cmake_fd_quiet_arg} - ${cmake_fd_required_arg} + find_package(${dep} ${ARGN} + ${cmake_fd_quiet_arg} + ${cmake_fd_required_arg} ) if(NOT DEFINED cmake_fd_alreadyTransitive OR cmake_fd_alreadyTransitive) @@ -67,7 +48,6 @@ macro(find_dependency dep) set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False) return() endif() - set(cmake_fd_version) set(cmake_fd_required_arg) set(cmake_fd_quiet_arg) set(cmake_fd_exact_arg) diff --git a/Tests/RunCMake/find_dependency/CMakeLists.txt b/Tests/RunCMake/find_dependency/CMakeLists.txt index 04d09f2..12cd3c7 100644 --- a/Tests/RunCMake/find_dependency/CMakeLists.txt +++ b/Tests/RunCMake/find_dependency/CMakeLists.txt @@ -1,4 +1,3 @@ cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) -set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}") include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/find_dependency/EXACT-no-version-result.txt b/Tests/RunCMake/find_dependency/EXACT-no-version-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/find_dependency/EXACT-no-version-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt b/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt deleted file mode 100644 index 348f8bb..0000000 --- a/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt +++ /dev/null @@ -1,6 +0,0 @@ -CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\): - Invalid arguments to find_dependency. EXACT may only be specified if a - VERSION is specified -Call Stack \(most recent call first\): - EXACT-no-version.cmake:4 \(find_dependency\) - CMakeLists.txt:4 \(include\) diff --git a/Tests/RunCMake/find_dependency/EXACT-no-version.cmake b/Tests/RunCMake/find_dependency/EXACT-no-version.cmake deleted file mode 100644 index b05665b7..0000000 --- a/Tests/RunCMake/find_dependency/EXACT-no-version.cmake +++ /dev/null @@ -1,4 +0,0 @@ - -include(CMakeFindDependencyMacro) - -find_dependency(Pack1 EXACT) diff --git a/Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake b/Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake deleted file mode 100644 index 7d55ef6..0000000 --- a/Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake +++ /dev/null @@ -1,2 +0,0 @@ - -add_library(Pack1::Lib INTERFACE IMPORTED) diff --git a/Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake b/Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake deleted file mode 100644 index dfb7b6c..0000000 --- a/Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake +++ /dev/null @@ -1,11 +0,0 @@ - -set(PACKAGE_VERSION "1.3") - -if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) - set(PACKAGE_VERSION_COMPATIBLE FALSE) -else() - set(PACKAGE_VERSION_COMPATIBLE TRUE) - if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") - set(PACKAGE_VERSION_EXACT TRUE) - endif() -endif() diff --git a/Tests/RunCMake/find_dependency/RunCMakeTest.cmake b/Tests/RunCMake/find_dependency/RunCMakeTest.cmake index 9403136..a72d189 100644 --- a/Tests/RunCMake/find_dependency/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_dependency/RunCMakeTest.cmake @@ -1,7 +1,10 @@ include(RunCMake) -run_cmake(EXACT-no-version) -run_cmake(empty-version) -run_cmake(empty-arg-3) -run_cmake(invalid-arg-3) -run_cmake(extra-args) +# Success tests +run_cmake(realistic) +run_cmake(basic) + +# Failure tests +run_cmake(invalid-arg) +run_cmake(bad-version-fuzzy) +run_cmake(bad-version-exact) diff --git a/Tests/RunCMake/find_dependency/bad-version-exact-result.txt b/Tests/RunCMake/find_dependency/bad-version-exact-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_dependency/bad-version-exact-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_dependency/bad-version-exact-stderr.txt b/Tests/RunCMake/find_dependency/bad-version-exact-stderr.txt new file mode 100644 index 0000000..0929f84 --- /dev/null +++ b/Tests/RunCMake/find_dependency/bad-version-exact-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at .*/Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(find_package\): + Could not find a configuration file for package "Pack1" that exactly + matches requested version "1.1". + + The following configuration files were considered but not accepted: + + .*/Tests/RunCMake/find_dependency/share/cmake/Pack1/Pack1Config.cmake, version: 1.3 + +Call Stack \(most recent call first\): + bad-version-exact.cmake:5 \(find_dependency\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_dependency/bad-version-exact.cmake b/Tests/RunCMake/find_dependency/bad-version-exact.cmake new file mode 100644 index 0000000..c4ca5e2 --- /dev/null +++ b/Tests/RunCMake/find_dependency/bad-version-exact.cmake @@ -0,0 +1,5 @@ +set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}") + +include(CMakeFindDependencyMacro) + +find_dependency(Pack1 1.1 EXACT REQUIRED) diff --git a/Tests/RunCMake/find_dependency/bad-version-fuzzy-result.txt b/Tests/RunCMake/find_dependency/bad-version-fuzzy-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_dependency/bad-version-fuzzy-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_dependency/bad-version-fuzzy-stderr.txt b/Tests/RunCMake/find_dependency/bad-version-fuzzy-stderr.txt new file mode 100644 index 0000000..c63256f --- /dev/null +++ b/Tests/RunCMake/find_dependency/bad-version-fuzzy-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at .*/Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(find_package\): + Could not find a configuration file for package "Pack1" that is compatible + with requested version "1.4". + + The following configuration files were considered but not accepted: + + .*/Tests/RunCMake/find_dependency/share/cmake/Pack1/Pack1Config.cmake, version: 1.3 + +Call Stack \(most recent call first\): + bad-version-fuzzy.cmake:5 \(find_dependency\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_dependency/bad-version-fuzzy.cmake b/Tests/RunCMake/find_dependency/bad-version-fuzzy.cmake new file mode 100644 index 0000000..c7cf4ee --- /dev/null +++ b/Tests/RunCMake/find_dependency/bad-version-fuzzy.cmake @@ -0,0 +1,5 @@ +set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}") + +include(CMakeFindDependencyMacro) + +find_dependency(Pack1 1.4 REQUIRED) diff --git a/Tests/RunCMake/find_dependency/basic.cmake b/Tests/RunCMake/find_dependency/basic.cmake new file mode 100644 index 0000000..c7795f2 --- /dev/null +++ b/Tests/RunCMake/find_dependency/basic.cmake @@ -0,0 +1,5 @@ +set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}") + +include(CMakeFindDependencyMacro) + +find_dependency(Pack1 1.1) diff --git a/Tests/RunCMake/find_dependency/empty-arg-3-result.txt b/Tests/RunCMake/find_dependency/empty-arg-3-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/find_dependency/empty-arg-3-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/find_dependency/empty-arg-3-stderr.txt b/Tests/RunCMake/find_dependency/empty-arg-3-stderr.txt deleted file mode 100644 index bf9b02b..0000000 --- a/Tests/RunCMake/find_dependency/empty-arg-3-stderr.txt +++ /dev/null @@ -1,5 +0,0 @@ -CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\): - Invalid arguments to find_dependency -Call Stack \(most recent call first\): - empty-arg-3.cmake:4 \(find_dependency\) - CMakeLists.txt:4 \(include\) diff --git a/Tests/RunCMake/find_dependency/empty-arg-3.cmake b/Tests/RunCMake/find_dependency/empty-arg-3.cmake deleted file mode 100644 index b08200a..0000000 --- a/Tests/RunCMake/find_dependency/empty-arg-3.cmake +++ /dev/null @@ -1,4 +0,0 @@ - -include(CMakeFindDependencyMacro) - -find_dependency(Pack1 1.2 "") diff --git a/Tests/RunCMake/find_dependency/empty-version-result.txt b/Tests/RunCMake/find_dependency/empty-version-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/find_dependency/empty-version-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/find_dependency/empty-version-stderr.txt b/Tests/RunCMake/find_dependency/empty-version-stderr.txt deleted file mode 100644 index b5e9f46..0000000 --- a/Tests/RunCMake/find_dependency/empty-version-stderr.txt +++ /dev/null @@ -1,5 +0,0 @@ -CMake Error at .*/Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\): - Invalid arguments to find_dependency. VERSION is empty -Call Stack \(most recent call first\): - empty-version.cmake:4 \(find_dependency\) - CMakeLists.txt:4 \(include\) diff --git a/Tests/RunCMake/find_dependency/empty-version.cmake b/Tests/RunCMake/find_dependency/empty-version.cmake deleted file mode 100644 index e6f17cd..0000000 --- a/Tests/RunCMake/find_dependency/empty-version.cmake +++ /dev/null @@ -1,4 +0,0 @@ - -include(CMakeFindDependencyMacro) - -find_dependency(Pack1 "") diff --git a/Tests/RunCMake/find_dependency/extra-args-result.txt b/Tests/RunCMake/find_dependency/extra-args-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/find_dependency/extra-args-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/find_dependency/extra-args-stderr.txt b/Tests/RunCMake/find_dependency/extra-args-stderr.txt deleted file mode 100644 index 83a7f02..0000000 --- a/Tests/RunCMake/find_dependency/extra-args-stderr.txt +++ /dev/null @@ -1,5 +0,0 @@ -CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\): - Invalid arguments to find_dependency -Call Stack \(most recent call first\): - extra-args.cmake:4 \(find_dependency\) - CMakeLists.txt:4 \(include\) diff --git a/Tests/RunCMake/find_dependency/extra-args.cmake b/Tests/RunCMake/find_dependency/extra-args.cmake deleted file mode 100644 index 209645a..0000000 --- a/Tests/RunCMake/find_dependency/extra-args.cmake +++ /dev/null @@ -1,4 +0,0 @@ - -include(CMakeFindDependencyMacro) - -find_dependency(Pack1 1.2 EXACT PATHS "${CMAKE_BINARY_DIR}") diff --git a/Tests/RunCMake/find_dependency/invalid-arg-3-result.txt b/Tests/RunCMake/find_dependency/invalid-arg-3-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/find_dependency/invalid-arg-3-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt b/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt deleted file mode 100644 index fee8d5d..0000000 --- a/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt +++ /dev/null @@ -1,5 +0,0 @@ -CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\): - Invalid arguments to find_dependency -Call Stack \(most recent call first\): - invalid-arg-3.cmake:4 \(find_dependency\) - CMakeLists.txt:4 \(include\) diff --git a/Tests/RunCMake/find_dependency/invalid-arg-3.cmake b/Tests/RunCMake/find_dependency/invalid-arg-3.cmake deleted file mode 100644 index 40ede07..0000000 --- a/Tests/RunCMake/find_dependency/invalid-arg-3.cmake +++ /dev/null @@ -1,4 +0,0 @@ - -include(CMakeFindDependencyMacro) - -find_dependency(Pack1 1.2 EXACTYPO) diff --git a/Tests/RunCMake/find_dependency/invalid-arg-result.txt b/Tests/RunCMake/find_dependency/invalid-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_dependency/invalid-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_dependency/invalid-arg-stderr.txt b/Tests/RunCMake/find_dependency/invalid-arg-stderr.txt new file mode 100644 index 0000000..16077b2 --- /dev/null +++ b/Tests/RunCMake/find_dependency/invalid-arg-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(find_package\): + find_package called with invalid argument "EXACTYPO" +Call Stack \(most recent call first\): + invalid-arg.cmake:5 \(find_dependency\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_dependency/invalid-arg.cmake b/Tests/RunCMake/find_dependency/invalid-arg.cmake new file mode 100644 index 0000000..daaf569 --- /dev/null +++ b/Tests/RunCMake/find_dependency/invalid-arg.cmake @@ -0,0 +1,5 @@ +set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}") + +include(CMakeFindDependencyMacro) + +find_dependency(Pack1 1.2 EXACTYPO) diff --git a/Tests/RunCMake/find_dependency/realistic.cmake b/Tests/RunCMake/find_dependency/realistic.cmake new file mode 100644 index 0000000..e633a31 --- /dev/null +++ b/Tests/RunCMake/find_dependency/realistic.cmake @@ -0,0 +1,3 @@ +set(Pack2_DIR "${CMAKE_CURRENT_SOURCE_DIR}/share/cmake/Pack2") + +find_package(Pack2 1.2 REQUIRED) diff --git a/Tests/RunCMake/find_dependency/share/cmake/Pack1/Pack1Config.cmake b/Tests/RunCMake/find_dependency/share/cmake/Pack1/Pack1Config.cmake new file mode 100644 index 0000000..7d55ef6 --- /dev/null +++ b/Tests/RunCMake/find_dependency/share/cmake/Pack1/Pack1Config.cmake @@ -0,0 +1,2 @@ + +add_library(Pack1::Lib INTERFACE IMPORTED) diff --git a/Tests/RunCMake/find_dependency/share/cmake/Pack1/Pack1ConfigVersion.cmake b/Tests/RunCMake/find_dependency/share/cmake/Pack1/Pack1ConfigVersion.cmake new file mode 100644 index 0000000..dfb7b6c --- /dev/null +++ b/Tests/RunCMake/find_dependency/share/cmake/Pack1/Pack1ConfigVersion.cmake @@ -0,0 +1,11 @@ + +set(PACKAGE_VERSION "1.3") + +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/Tests/RunCMake/find_dependency/share/cmake/Pack2/Pack2Config.cmake b/Tests/RunCMake/find_dependency/share/cmake/Pack2/Pack2Config.cmake new file mode 100644 index 0000000..7e8a60b --- /dev/null +++ b/Tests/RunCMake/find_dependency/share/cmake/Pack2/Pack2Config.cmake @@ -0,0 +1,6 @@ +include(CMakeFindDependencyMacro) + +find_dependency(Pack1 PATHS ${CMAKE_CURRENT_LIST_DIR}/..) + +add_library(Pack2::Lib INTERFACE IMPORTED) +set_target_properties(Pack2::Lib PROPERTIES INTERFACE_LINK_LIBRARIES Pack1::Lib) diff --git a/Tests/RunCMake/find_dependency/share/cmake/Pack2/Pack2ConfigVersion.cmake b/Tests/RunCMake/find_dependency/share/cmake/Pack2/Pack2ConfigVersion.cmake new file mode 100644 index 0000000..dfb7b6c --- /dev/null +++ b/Tests/RunCMake/find_dependency/share/cmake/Pack2/Pack2ConfigVersion.cmake @@ -0,0 +1,11 @@ + +set(PACKAGE_VERSION "1.3") + +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() -- cgit v0.12