diff options
author | Brad King <brad.king@kitware.com> | 2022-06-07 14:55:21 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-06-07 14:55:29 (GMT) |
commit | bdd44eca9b5a458b981caff1010a84ca2aa70819 (patch) | |
tree | e0b63f8d760cb4e885fc5664901ca043683ce0b7 /Tests | |
parent | 4a7bb7b2550905efc20424490b293934f91e072d (diff) | |
parent | d8dcfa7776002756efbc30e45be305e425103e31 (diff) | |
download | CMake-bdd44eca9b5a458b981caff1010a84ca2aa70819.zip CMake-bdd44eca9b5a458b981caff1010a84ca2aa70819.tar.gz CMake-bdd44eca9b5a458b981caff1010a84ca2aa70819.tar.bz2 |
Merge topic 'print-sources'
d8dcfa7776 Tests: Add tests for CMakePrintHelpers
b7ddfcfe08 cmake_print_properties(): Update grammar docs
e52b9e1270 PrintHelpers: Document argument order restriction
d87ed4d88f PrintHelpers: Fix indentation
5fa70e1738 PrintHelpers: Rewrite a few more error messages
2579503f45 PrintHelpers: Fix target SOURCES property
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7331
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/PrintHelpers/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/PrintHelpers/Properties-stdout.txt | 14 | ||||
-rw-r--r-- | Tests/RunCMake/PrintHelpers/Properties.cmake | 26 | ||||
-rw-r--r-- | Tests/RunCMake/PrintHelpers/PropertiesSources-stdout.cmake | 8 | ||||
-rw-r--r-- | Tests/RunCMake/PrintHelpers/PropertiesSources.cmake | 19 | ||||
-rw-r--r-- | Tests/RunCMake/PrintHelpers/RunCMakeTest.cmake | 5 | ||||
-rw-r--r-- | Tests/RunCMake/PrintHelpers/Variables-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/PrintHelpers/Variables.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/PrintHelpers/nothing.c | 6 | ||||
-rw-r--r-- | Tests/RunCMake/PrintHelpers/nothing.h | 8 | ||||
-rw-r--r-- | Tests/RunCMake/PrintHelpers/rot13.c | 15 | ||||
-rw-r--r-- | Tests/RunCMake/PrintHelpers/rot13.h | 9 | ||||
-rw-r--r-- | Tests/RunCMake/PrintHelpers/something.c | 7 | ||||
-rw-r--r-- | Tests/RunCMake/PrintHelpers/something.h | 8 |
15 files changed, 136 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 7e17450..4b00212 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -465,6 +465,7 @@ add_RunCMake_test(load_cache) add_RunCMake_test(math) add_RunCMake_test(message) add_RunCMake_test(option) +add_RunCMake_test(PrintHelpers) add_RunCMake_test(project -DCMake_TEST_RESOURCES=${CMake_TEST_RESOURCES}) add_RunCMake_test(project_injected) add_RunCMake_test(DependencyProviders) diff --git a/Tests/RunCMake/PrintHelpers/CMakeLists.txt b/Tests/RunCMake/PrintHelpers/CMakeLists.txt new file mode 100644 index 0000000..6d4fe63 --- /dev/null +++ b/Tests/RunCMake/PrintHelpers/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.23) +project(${RunCMake_TEST} C) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/PrintHelpers/Properties-stdout.txt b/Tests/RunCMake/PrintHelpers/Properties-stdout.txt new file mode 100644 index 0000000..c52f7b6 --- /dev/null +++ b/Tests/RunCMake/PrintHelpers/Properties-stdout.txt @@ -0,0 +1,14 @@ +.*Properties for TARGET nothing:.* +.*nothing.LINKER_LANGUAGE = <NOTFOUND>.* +.*nothing.TYPE = \"STATIC_LIBRARY\".* +.*Properties for TARGET something:.* +.*something.LINKER_LANGUAGE = <NOTFOUND>.* +.*something.TYPE = \"EXECUTABLE\".* ++ +.* +.*Properties for SOURCE nothing.c:.* +.*nothing.c.COMPILE_DEFINITIONS = <NOTFOUND>.* +.*nothing.c.LANGUAGE = \"C\".* +.*Properties for SOURCE something.c:.* +.*something.c.COMPILE_DEFINITIONS = \"SOMETHING=1\".* +.*something.c.LANGUAGE = \"C\".* diff --git a/Tests/RunCMake/PrintHelpers/Properties.cmake b/Tests/RunCMake/PrintHelpers/Properties.cmake new file mode 100644 index 0000000..3e8ecd1 --- /dev/null +++ b/Tests/RunCMake/PrintHelpers/Properties.cmake @@ -0,0 +1,26 @@ +enable_language(C) + +set_property(SOURCE nothing.c PROPERTY LANGUAGE C) +set_property(SOURCE something.c PROPERTY + COMPILE_DEFINITIONS SOMETHING=1) + +add_library(nothing STATIC nothing.c nothing.h) + +add_executable(something something.c something.h) +target_link_libraries(something PUBLIC nothing) + +include(CMakePrintHelpers) + +cmake_print_properties( + TARGETS nothing something + PROPERTIES + LINKER_LANGUAGE + TYPE +) + +cmake_print_properties( + SOURCES nothing.c something.c + PROPERTIES + COMPILE_DEFINITIONS + LANGUAGE +) diff --git a/Tests/RunCMake/PrintHelpers/PropertiesSources-stdout.cmake b/Tests/RunCMake/PrintHelpers/PropertiesSources-stdout.cmake new file mode 100644 index 0000000..93b3df0 --- /dev/null +++ b/Tests/RunCMake/PrintHelpers/PropertiesSources-stdout.cmake @@ -0,0 +1,8 @@ +.*Properties for TARGET rot13:.* +.*rot13.SOURCES = \"rot13.c;rot13.h\".* +.*rot13.POSITION_INDEPENDENT_CODE = \"True\".* ++ +.*--.* +.*Properties for SOURCE rot13.c:.* +.*rot13.c.LOCATION = \"[^\"]*/PrintHelpers/rot13.c\".* +.*rot13.c.LANGUAGE = \"C\".* diff --git a/Tests/RunCMake/PrintHelpers/PropertiesSources.cmake b/Tests/RunCMake/PrintHelpers/PropertiesSources.cmake new file mode 100644 index 0000000..f102b94 --- /dev/null +++ b/Tests/RunCMake/PrintHelpers/PropertiesSources.cmake @@ -0,0 +1,19 @@ +set_property(SOURCE rot13.c PROPERTY LANGUAGE C) + +add_library(rot13 SHARED rot13.c rot13.h) + +include(CMakePrintHelpers) + +cmake_print_properties( + TARGETS rot13 + PROPERTIES + SOURCES + POSITION_INDEPENDENT_CODE +) + +cmake_print_properties( + SOURCES rot13.c + PROPERTIES + LOCATION + LANGUAGE +) diff --git a/Tests/RunCMake/PrintHelpers/RunCMakeTest.cmake b/Tests/RunCMake/PrintHelpers/RunCMakeTest.cmake new file mode 100644 index 0000000..5b8ad0c --- /dev/null +++ b/Tests/RunCMake/PrintHelpers/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(Variables) +run_cmake(Properties) +run_cmake(PropertiesSources) diff --git a/Tests/RunCMake/PrintHelpers/Variables-stdout.txt b/Tests/RunCMake/PrintHelpers/Variables-stdout.txt new file mode 100644 index 0000000..ca95c8d --- /dev/null +++ b/Tests/RunCMake/PrintHelpers/Variables-stdout.txt @@ -0,0 +1 @@ +-- source_dir="src" ; binary_dir="build" diff --git a/Tests/RunCMake/PrintHelpers/Variables.cmake b/Tests/RunCMake/PrintHelpers/Variables.cmake new file mode 100644 index 0000000..88f5ad1 --- /dev/null +++ b/Tests/RunCMake/PrintHelpers/Variables.cmake @@ -0,0 +1,6 @@ + +set(source_dir "src") +set(binary_dir "build") + +include(CMakePrintHelpers) +cmake_print_variables(source_dir binary_dir) diff --git a/Tests/RunCMake/PrintHelpers/nothing.c b/Tests/RunCMake/PrintHelpers/nothing.c new file mode 100644 index 0000000..32b7b39 --- /dev/null +++ b/Tests/RunCMake/PrintHelpers/nothing.c @@ -0,0 +1,6 @@ +#include "nothing.h" + +void nothing() +{ + (void*)0; +} diff --git a/Tests/RunCMake/PrintHelpers/nothing.h b/Tests/RunCMake/PrintHelpers/nothing.h new file mode 100644 index 0000000..ae86667 --- /dev/null +++ b/Tests/RunCMake/PrintHelpers/nothing.h @@ -0,0 +1,8 @@ +#ifndef NOTHING_H +#define NOTHING_H + +#include <stdlib.h> + +void nothing(); + +#endif diff --git a/Tests/RunCMake/PrintHelpers/rot13.c b/Tests/RunCMake/PrintHelpers/rot13.c new file mode 100644 index 0000000..053bebd --- /dev/null +++ b/Tests/RunCMake/PrintHelpers/rot13.c @@ -0,0 +1,15 @@ +#include "rot13.h" + +void rot13(char* in) +{ + char* end = in + strlen(in); + for (char* c = in; c < end; c++) { + if (*c >= 'a' && *c <= 'z') { + *c += (*c < 'n') ? 13 : -13; + continue; + } + if (*c >= 'A' && *c <= 'Z') { + *c += (*c < 'N') ? 13 : -13; + } + } +} diff --git a/Tests/RunCMake/PrintHelpers/rot13.h b/Tests/RunCMake/PrintHelpers/rot13.h new file mode 100644 index 0000000..9afea5f --- /dev/null +++ b/Tests/RunCMake/PrintHelpers/rot13.h @@ -0,0 +1,9 @@ +#ifndef ROT13_H +#define ROT13_H + +#include <stdlib.h> +#include <string.h> + +void rot13(char* in); + +#endif diff --git a/Tests/RunCMake/PrintHelpers/something.c b/Tests/RunCMake/PrintHelpers/something.c new file mode 100644 index 0000000..a2bc425 --- /dev/null +++ b/Tests/RunCMake/PrintHelpers/something.c @@ -0,0 +1,7 @@ +#include "something.h" + +int main() +{ + nothing(); + return 0; +} diff --git a/Tests/RunCMake/PrintHelpers/something.h b/Tests/RunCMake/PrintHelpers/something.h new file mode 100644 index 0000000..667ee99 --- /dev/null +++ b/Tests/RunCMake/PrintHelpers/something.h @@ -0,0 +1,8 @@ +#ifndef SOMETHING_H +#define SOMETHING_H + +#include <stdlib.h> + +#include "nothing.h" + +#endif |