diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2023-07-25 18:20:12 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2023-07-29 13:35:20 (GMT) |
commit | 16c24cce4775d46787cc27fe49108271d6bcf167 (patch) | |
tree | f3d76a9406bda0ac66264971b76f419310749998 /Tests/RunCMake/property_init | |
parent | f81351607c343517f3fa48ca93dfaf2a33688c84 (diff) | |
download | CMake-16c24cce4775d46787cc27fe49108271d6bcf167.zip CMake-16c24cce4775d46787cc27fe49108271d6bcf167.tar.gz CMake-16c24cce4775d46787cc27fe49108271d6bcf167.tar.bz2 |
Tests/RunCMake/property_init: add a function to check a property
Diffstat (limited to 'Tests/RunCMake/property_init')
-rw-r--r-- | Tests/RunCMake/property_init/util.cmake | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Tests/RunCMake/property_init/util.cmake b/Tests/RunCMake/property_init/util.cmake new file mode 100644 index 0000000..52d0961 --- /dev/null +++ b/Tests/RunCMake/property_init/util.cmake @@ -0,0 +1,24 @@ +function (check_property target property expected) + if (NOT TARGET "${target}") + message(SEND_ERROR + "No such target '${target}'") + return () + endif () + + get_property(is_set TARGET "${target}" PROPERTY "${property}" SET) + if (is_set) + get_property(actual TARGET "${target}" PROPERTY "${property}") + endif () + if (expected STREQUAL "<UNSET>") + if (is_set) + message(SEND_ERROR + "Target '${target}' should not have '${property}' set at all, but is '${actual}'") + endif () + elseif (is_set AND NOT expected STREQUAL actual) + message(SEND_ERROR + "Target '${target}' should have '${property}' set to '${expected}', but is '${actual}'") + elseif (NOT is_set) + message(SEND_ERROR + "Target '${target}' should have '${property}' set to '${expected}', but is not set at all") + endif () +endfunction () |