diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:41:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:41:38 +0000 |
commit | 7b6e527f440cd7e6f8be2b07cee320ee6ca18786 (patch) | |
tree | 4a2738d69fa2814659fdadddf5826282e73d81f4 /test cases/unit/63 cmake parser | |
parent | Initial commit. (diff) | |
download | meson-7b6e527f440cd7e6f8be2b07cee320ee6ca18786.tar.xz meson-7b6e527f440cd7e6f8be2b07cee320ee6ca18786.zip |
Adding upstream version 1.0.1.upstream/1.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test cases/unit/63 cmake parser')
-rw-r--r-- | test cases/unit/63 cmake parser/meson.build | 19 | ||||
-rw-r--r-- | test cases/unit/63 cmake parser/prefix/lib/cmake/mesontest/mesontest-config.cmake | 63 |
2 files changed, 82 insertions, 0 deletions
diff --git a/test cases/unit/63 cmake parser/meson.build b/test cases/unit/63 cmake parser/meson.build new file mode 100644 index 0000000..472561d --- /dev/null +++ b/test cases/unit/63 cmake parser/meson.build @@ -0,0 +1,19 @@ +project('61 cmake parser') + +dep = dependency('mesontest') + +# Test a bunch of variations of the set() command +assert(dep.get_variable(cmake : 'VAR_WITHOUT_SPACES') == 'NoSpaces', 'set() without spaces incorrect') +assert(dep.get_variable(cmake : 'VAR_WITH_SPACES') == 'With Spaces', 'set() with spaces incorrect') + +assert(dep.get_variable(cmake : 'VAR_WITHOUT_SPACES_PS') == 'NoSpaces', 'set(PARENT_SCOPE) without spaces incorrect') +assert(dep.get_variable(cmake : 'VAR_WITH_SPACES_PS') == 'With Spaces', 'set(PARENT_SCOPE) with spaces incorrect') + +assert(dep.get_variable(cmake : 'VAR_THAT_IS_UNSET', default_value : 'sentinal') == 'sentinal', 'set() to unset is incorrect') +assert(dep.get_variable(cmake : 'CACHED_STRING_NS') == 'foo', 'set(CACHED) without spaces is incorrect') +assert(dep.get_variable(cmake : 'CACHED_STRING_WS') == 'foo bar', 'set(CACHED STRING) with spaces is incorrect') +assert(dep.get_variable(cmake : 'CACHED_STRING_ARRAY_NS') == 'foo;bar', 'set(CACHED STRING) without spaces is incorrect') +assert(dep.get_variable(cmake : 'CACHED_STRING_ARRAY_WS') == 'foo;foo bar;bar', 'set(CACHED STRING[]) with spaces is incorrect') + +# We don't support this, so it should be unset. +assert(dep.get_variable(cmake : 'ENV{var}', default_value : 'sentinal') == 'sentinal', 'set(ENV) should be ignored') diff --git a/test cases/unit/63 cmake parser/prefix/lib/cmake/mesontest/mesontest-config.cmake b/test cases/unit/63 cmake parser/prefix/lib/cmake/mesontest/mesontest-config.cmake new file mode 100644 index 0000000..7474eb7 --- /dev/null +++ b/test cases/unit/63 cmake parser/prefix/lib/cmake/mesontest/mesontest-config.cmake @@ -0,0 +1,63 @@ +# This should be enough to satisfy the basic parser +set(MESONTEST_VERSION "1.2.3") +set(MESONTEST_LIBRARIES "foo.so") +set(MESONTEST_INCLUDE_DIR "") +set(MESONTEST_FOUND "TRUE") + +## Tests for set() in its various forms + +# Basic usage +set(VAR_WITHOUT_SPACES "NoSpaces") +set(VAR_WITH_SPACES "With Spaces") + +# test of PARENT_SCOPE, requires a function to have a parent scope obviously... +function(foo) + set(VAR_WITHOUT_SPACES_PS "NoSpaces" PARENT_SCOPE) + set(VAR_WITH_SPACES_PS "With Spaces" PARENT_SCOPE) +endfunction(foo) +foo() + +# Using set() to unset values +set(VAR_THAT_IS_UNSET "foo") +set(VAR_THAT_IS_UNSET) + +# The more advanced form that uses CACHE +# XXX: Why don't we read the type and use that instead of always treat things as strings? +set(CACHED_STRING_NS "foo" CACHE STRING "docstring") +set(CACHED_STRING_WS "foo bar" CACHE STRING "docstring") +set(CACHED_STRING_ARRAY_NS "foo;bar" CACHE STRING "doc string") +set(CACHED_STRING_ARRAY_WS "foo;foo bar;bar" CACHE STRING "stuff" FORCE) + +set(CACHED_BOOL ON CACHE BOOL "docstring") + +set(CACHED_PATH_NS "foo/bar" CACHE PATH "docstring") +set(CACHED_PATH_WS "foo bar/fin" CACHE PATH "docstring") + +set(CACHED_FILEPATH_NS "foo/bar.txt" CACHE FILEPATH "docstring") +set(CACHED_FILEPATH_WS "foo bar/fin.txt" CACHE FILEPATH "docstring") + +# Set ENV, we don't support this so it shouldn't be showing up +set(ENV{var}, "foo") + + +## Tests for set_properties() +# We need something to attach properties too +add_custom_target(MESONTEST_FOO ALL) + +set_property(TARGET MESONTEST_FOO PROPERTY FOLDER "value") +set_property(TARGET MESONTEST_FOO APPEND PROPERTY FOLDER "name") +set_property(TARGET MESONTEST_FOO PROPERTY FOLDER "value") +set_property(TARGET MESONTEST_FOO APPEND_STRING PROPERTY FOLDER "name") + +set_property(TARGET MESONTEST_FOO PROPERTY FOLDER "value space") +set_property(TARGET MESONTEST_FOO PROPERTY FOLDER "value space") +set_property(TARGET MESONTEST_FOO APPEND PROPERTY FOLDER "name space") +set_property(TARGET MESONTEST_FOO PROPERTY FOLDER "value space") +set_property(TARGET MESONTEST_FOO APPEND_STRING PROPERTY FOLDER "name space") + +## Tests for set_target_properties() +set_target_properties(MESONTEST_FOO PROPERTIES FOLDER "value") +set_target_properties(MESONTEST_FOO PROPERTIES FOLDER "value space") +set_target_properties(MESONTEST_FOO PROPERTIES FOLDER "value" OUTPUT_NAME "another value") +set_target_properties(MESONTEST_FOO PROPERTIES FOLDER "value space" OUTPUT_NAME "another value") +set_target_properties(MESONTEST_FOO PROPERTIES FOLDER "value space" OUTPUT_NAME "value")
\ No newline at end of file |