summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2023-07-25 18:21:49 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2023-07-29 13:35:20 (GMT)
commit7b9378be43ac244baefb03bd7ab34ae882d3c1f1 (patch)
tree02442c7317f9ae9f4ca9bc8f1e63d1a1c7e4734b
parent16c24cce4775d46787cc27fe49108271d6bcf167 (diff)
downloadCMake-7b9378be43ac244baefb03bd7ab34ae882d3c1f1.zip
CMake-7b9378be43ac244baefb03bd7ab34ae882d3c1f1.tar.gz
CMake-7b9378be43ac244baefb03bd7ab34ae882d3c1f1.tar.bz2
Tests/RunCMake/property_init: add a function to parse property tables
The tables will be triples of property / value / alias value. Parsing is a bit tricky, but is easier when `foreach (IN ZIP_LISTS)` with the values in their distinct list.
-rw-r--r--Tests/RunCMake/property_init/util.cmake29
1 files changed, 29 insertions, 0 deletions
diff --git a/Tests/RunCMake/property_init/util.cmake b/Tests/RunCMake/property_init/util.cmake
index 52d0961..41a200a 100644
--- a/Tests/RunCMake/property_init/util.cmake
+++ b/Tests/RunCMake/property_init/util.cmake
@@ -22,3 +22,32 @@ function (check_property target property expected)
"Target '${target}' should have '${property}' set to '${expected}', but is not set at all")
endif ()
endfunction ()
+
+function (prepare_properties table output_properties output_expected output_alias)
+ set(_properties)
+ set(_expected)
+ set(_alias)
+
+ set(variable "_properties")
+ foreach (item IN LISTS "${table}")
+ list(APPEND "${variable}" "${item}")
+ if (variable STREQUAL "_properties")
+ set(variable "_expected")
+ elseif (variable STREQUAL "_expected")
+ set(variable "_alias")
+ elseif (variable STREQUAL "_alias")
+ set(variable "_properties")
+ else ()
+ message(FATAL_ERROR
+ "Failed to track property table parsing")
+ endif ()
+ endforeach ()
+ if (NOT variable STREQUAL "_properties")
+ message(FATAL_ERROR
+ "Table does not have a multiple of 3 items")
+ endif ()
+
+ set("${output_properties}" "${_properties}" PARENT_SCOPE)
+ set("${output_expected}" "${_expected}" PARENT_SCOPE)
+ set("${output_alias}" "${_alias}" PARENT_SCOPE)
+endfunction ()