summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-05-01 12:32:02 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-05-01 12:33:30 (GMT)
commit6556e587efa8ad954126137c6ca867f1f2797b11 (patch)
tree29942e95d7c5378b84c01012f932d47b7e0adbad /Tests
parent9026ef003de06b9dddf47bf428e19371f6251ccc (diff)
parent0b6332af6085b97830091e1f973f48481e8fa890 (diff)
downloadCMake-6556e587efa8ad954126137c6ca867f1f2797b11.zip
CMake-6556e587efa8ad954126137c6ca867f1f2797b11.tar.gz
CMake-6556e587efa8ad954126137c6ca867f1f2797b11.tar.bz2
Merge topic 'FPHSA-handle-components'
0b6332af60 FPHSA: REQUIRED_VARS is optional if HANDLE_COMPONENTS is specified Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4690
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/FPHSA/FindUseComponents.cmake15
-rw-r--r--Tests/RunCMake/FPHSA/RunCMakeTest.cmake8
-rw-r--r--Tests/RunCMake/FPHSA/all_optional_components.cmake14
-rw-r--r--Tests/RunCMake/FPHSA/required_and_optional_components.cmake14
-rw-r--r--Tests/RunCMake/FPHSA/required_components.cmake11
-rw-r--r--Tests/RunCMake/FPHSA/required_components_with_vars.cmake1
6 files changed, 63 insertions, 0 deletions
diff --git a/Tests/RunCMake/FPHSA/FindUseComponents.cmake b/Tests/RunCMake/FPHSA/FindUseComponents.cmake
new file mode 100644
index 0000000..4168f1d
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/FindUseComponents.cmake
@@ -0,0 +1,15 @@
+# pseudo find_module
+
+if (UseComponents_REQUIRE_VARS)
+ set(FOOBAR TRUE)
+ set(REQUIRED_VARS REQUIRED_VARS FOOBAR)
+endif()
+
+set (UseComponents_Comp1_FOUND TRUE)
+set (UseComponents_Comp2_FOUND TRUE)
+set (UseComponents_Comp3_FOUND FALSE)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(UseComponents ${REQUIRED_VARS}
+ VERSION_VAR Pseudo_VERSION
+ HANDLE_COMPONENTS)
diff --git a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake
index 286915d..8e39090 100644
--- a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake
+++ b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake
@@ -47,3 +47,11 @@ run_cmake(custom_message_1)
set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DCONFIG_MODE=TRUE")
run_cmake(custom_message_2)
run_cmake(custom_message_3)
+
+# check handling of components
+set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DUseComponents_VERSION=1.2.3.4")
+run_cmake(required_components)
+run_cmake(required_and_optional_components)
+run_cmake(all_optional_components)
+list(APPEND RunCMake_TEST_OPTIONS "-DUseComponents_REQUIRE_VARS=TRUE")
+run_cmake(required_components_with_vars)
diff --git a/Tests/RunCMake/FPHSA/all_optional_components.cmake b/Tests/RunCMake/FPHSA/all_optional_components.cmake
new file mode 100644
index 0000000..f4d8b5e
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/all_optional_components.cmake
@@ -0,0 +1,14 @@
+find_package(UseComponents OPTIONAL_COMPONENTS Comp1 Comp2 Comp3)
+
+if (NOT UseComponents_FOUND)
+ message (FATAL_ERROR "package UseComponents Not Found.")
+endif()
+if (NOT UseComponents_Comp1_FOUND)
+ message (FATAL_ERROR "package UseComponents, component Comp1 not found.")
+endif()
+if (NOT UseComponents_Comp2_FOUND)
+ message (FATAL_ERROR "package UseComponents, component Comp2 not found.")
+endif()
+if (UseComponents_Comp3_FOUND)
+ message (FATAL_ERROR "package UseComponents, component Comp2 unexpectedly found.")
+endif()
diff --git a/Tests/RunCMake/FPHSA/required_and_optional_components.cmake b/Tests/RunCMake/FPHSA/required_and_optional_components.cmake
new file mode 100644
index 0000000..836dcac
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/required_and_optional_components.cmake
@@ -0,0 +1,14 @@
+find_package(UseComponents COMPONENTS Comp1 Comp2 OPTIONAL_COMPONENTS Comp3)
+
+if (NOT UseComponents_FOUND)
+ message (FATAL_ERROR "package UseComponents Not Found.")
+endif()
+if (NOT UseComponents_Comp1_FOUND)
+ message (FATAL_ERROR "package UseComponents, component Comp1 not found.")
+endif()
+if (NOT UseComponents_Comp2_FOUND)
+ message (FATAL_ERROR "package UseComponents, component Comp2 not found.")
+endif()
+if (UseComponents_Comp3_FOUND)
+ message (FATAL_ERROR "package UseComponents, component Comp2 unexpectedly found.")
+endif()
diff --git a/Tests/RunCMake/FPHSA/required_components.cmake b/Tests/RunCMake/FPHSA/required_components.cmake
new file mode 100644
index 0000000..0dd8e9c
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/required_components.cmake
@@ -0,0 +1,11 @@
+find_package(UseComponents COMPONENTS Comp1 Comp2)
+
+if (NOT UseComponents_FOUND)
+ message (FATAL_ERROR "package UseComponents Not Found.")
+endif()
+if (NOT UseComponents_Comp1_FOUND)
+ message (FATAL_ERROR "package UseComponents, component Comp1 Not Found.")
+endif()
+if (NOT UseComponents_Comp2_FOUND)
+ message (FATAL_ERROR "package UseComponents, component Comp2 Not Found.")
+endif()
diff --git a/Tests/RunCMake/FPHSA/required_components_with_vars.cmake b/Tests/RunCMake/FPHSA/required_components_with_vars.cmake
new file mode 100644
index 0000000..842ef15
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/required_components_with_vars.cmake
@@ -0,0 +1 @@
+include ("required_components.cmake")