From 7b9378be43ac244baefb03bd7ab34ae882d3c1f1 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 25 Jul 2023 14:21:49 -0400 Subject: 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. --- Tests/RunCMake/property_init/util.cmake | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) 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 () -- cgit v0.12