From 45abfb0c4d622c86880b2b32619f79417410a6c8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 6 Mar 2014 15:06:22 +0100 Subject: find_dependency: Extend the tests for use of EXACT macro parameter. --- Tests/Module/FindDependency/CMakeLists.txt | 3 ++- Tests/Module/FindDependency/main.cpp | 12 ++++++++++++ Tests/Module/FindDependency/packages/Pack4/Pack4Config.cmake | 9 +++++++++ .../FindDependency/packages/Pack4/Pack4ConfigVersion.cmake | 11 +++++++++++ Tests/Module/FindDependency/packages/Pack5/Pack5Config.cmake | 3 +++ .../FindDependency/packages/Pack5/Pack5ConfigVersion.cmake | 11 +++++++++++ Tests/Module/FindDependency/packages/Pack6/Pack6Config.cmake | 3 +++ .../FindDependency/packages/Pack6/Pack6ConfigVersion.cmake | 11 +++++++++++ 8 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 Tests/Module/FindDependency/packages/Pack4/Pack4Config.cmake create mode 100644 Tests/Module/FindDependency/packages/Pack4/Pack4ConfigVersion.cmake create mode 100644 Tests/Module/FindDependency/packages/Pack5/Pack5Config.cmake create mode 100644 Tests/Module/FindDependency/packages/Pack5/Pack5ConfigVersion.cmake create mode 100644 Tests/Module/FindDependency/packages/Pack6/Pack6Config.cmake create mode 100644 Tests/Module/FindDependency/packages/Pack6/Pack6ConfigVersion.cmake diff --git a/Tests/Module/FindDependency/CMakeLists.txt b/Tests/Module/FindDependency/CMakeLists.txt index b13f48a..dcb998a 100644 --- a/Tests/Module/FindDependency/CMakeLists.txt +++ b/Tests/Module/FindDependency/CMakeLists.txt @@ -5,6 +5,7 @@ project(FindDependency) set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/packages") find_package(Pack1 REQUIRED) +find_package(Pack4 4.3 EXACT REQUIRED) add_executable(FindDependency main.cpp) -target_link_libraries(FindDependency Pack1::Lib) +target_link_libraries(FindDependency Pack1::Lib Pack4::Lib) diff --git a/Tests/Module/FindDependency/main.cpp b/Tests/Module/FindDependency/main.cpp index d635b31..50c5958 100644 --- a/Tests/Module/FindDependency/main.cpp +++ b/Tests/Module/FindDependency/main.cpp @@ -11,6 +11,18 @@ #error Expected HAVE_PACK3 #endif +#ifndef HAVE_PACK4 +#error Expected HAVE_PACK4 +#endif + +#ifndef HAVE_PACK5 +#error Expected HAVE_PACK5 +#endif + +#ifndef HAVE_PACK6 +#error Expected HAVE_PACK6 +#endif + int main(int argc, char** argv) { return 0; diff --git a/Tests/Module/FindDependency/packages/Pack4/Pack4Config.cmake b/Tests/Module/FindDependency/packages/Pack4/Pack4Config.cmake new file mode 100644 index 0000000..62fddb1 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack4/Pack4Config.cmake @@ -0,0 +1,9 @@ + +include(CMakeFindDependencyMacro) + +find_dependency(Pack5 3.1) # Actual version is 3.3. EXACT not propagated. +find_dependency(Pack6 5.5 EXACT) + +add_library(Pack4::Lib INTERFACE IMPORTED) +set_property(TARGET Pack4::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK4) +set_property(TARGET Pack4::Lib PROPERTY INTERFACE_LINK_LIBRARIES Pack5::Lib Pack6::Lib) diff --git a/Tests/Module/FindDependency/packages/Pack4/Pack4ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack4/Pack4ConfigVersion.cmake new file mode 100644 index 0000000..ae982b0 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack4/Pack4ConfigVersion.cmake @@ -0,0 +1,11 @@ + +set(PACKAGE_VERSION "4.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/Module/FindDependency/packages/Pack5/Pack5Config.cmake b/Tests/Module/FindDependency/packages/Pack5/Pack5Config.cmake new file mode 100644 index 0000000..1edda9a --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack5/Pack5Config.cmake @@ -0,0 +1,3 @@ + +add_library(Pack5::Lib INTERFACE IMPORTED) +set_property(TARGET Pack5::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK5) diff --git a/Tests/Module/FindDependency/packages/Pack5/Pack5ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack5/Pack5ConfigVersion.cmake new file mode 100644 index 0000000..e944f96 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack5/Pack5ConfigVersion.cmake @@ -0,0 +1,11 @@ + +set(PACKAGE_VERSION "3.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/Module/FindDependency/packages/Pack6/Pack6Config.cmake b/Tests/Module/FindDependency/packages/Pack6/Pack6Config.cmake new file mode 100644 index 0000000..d6c85fb --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack6/Pack6Config.cmake @@ -0,0 +1,3 @@ + +add_library(Pack6::Lib INTERFACE IMPORTED) +set_property(TARGET Pack6::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK6) diff --git a/Tests/Module/FindDependency/packages/Pack6/Pack6ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack6/Pack6ConfigVersion.cmake new file mode 100644 index 0000000..0dd00d2 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack6/Pack6ConfigVersion.cmake @@ -0,0 +1,11 @@ + +set(PACKAGE_VERSION "5.5") + +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