summaryrefslogtreecommitdiffstats
path: root/Tests/GeneratorExpression
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@sap.com>2017-11-30 14:06:21 (GMT)
committerMarc Chevrier <marc.chevrier@sap.com>2017-12-05 13:47:39 (GMT)
commit9432f686e62082045f53bd0ec8f8911966476df1 (patch)
tree9e03e1ae0c08fa693fbfb741b763d45c78b5feef /Tests/GeneratorExpression
parentd06b8264212c893b5da8d7499328eb403aaaad37 (diff)
downloadCMake-9432f686e62082045f53bd0ec8f8911966476df1.zip
CMake-9432f686e62082045f53bd0ec8f8911966476df1.tar.gz
CMake-9432f686e62082045f53bd0ec8f8911966476df1.tar.bz2
Add generator expression support to per-source COMPILE_DEFINITIONS
This allows users to specify different genex-based compile definitions for each file in a target. Fixes: #17508
Diffstat (limited to 'Tests/GeneratorExpression')
-rw-r--r--Tests/GeneratorExpression/CMakeLists.txt9
-rw-r--r--Tests/GeneratorExpression/srcgenex_defs.c (renamed from Tests/GeneratorExpression/srcgenex.c)2
-rw-r--r--Tests/GeneratorExpression/srcgenex_flags.c12
3 files changed, 20 insertions, 3 deletions
diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt
index 83fd11d..5165970 100644
--- a/Tests/GeneratorExpression/CMakeLists.txt
+++ b/Tests/GeneratorExpression/CMakeLists.txt
@@ -258,8 +258,13 @@ add_custom_target(check-part4 ALL
VERBATIM
)
-add_executable(srcgenex srcgenex.c)
-set_property(SOURCE srcgenex.c PROPERTY COMPILE_FLAGS "-DNAME=$<TARGET_PROPERTY:NAME>")
+#-----------------------------------------------------------------------------
+# Cover source file properties with generator expressions.
+add_executable(srcgenex_flags srcgenex_flags.c)
+set_property(SOURCE srcgenex_flags.c PROPERTY COMPILE_FLAGS "-DNAME=$<TARGET_PROPERTY:NAME>")
+
+add_executable(srcgenex_defs srcgenex_defs.c)
+set_property(SOURCE srcgenex_defs.c PROPERTY COMPILE_DEFINITIONS NAME=$<TARGET_PROPERTY:NAME>)
#-----------------------------------------------------------------------------
# Cover test properties with generator expressions.
diff --git a/Tests/GeneratorExpression/srcgenex.c b/Tests/GeneratorExpression/srcgenex_defs.c
index 56d3c3f..883e631 100644
--- a/Tests/GeneratorExpression/srcgenex.c
+++ b/Tests/GeneratorExpression/srcgenex_defs.c
@@ -1,4 +1,4 @@
-int srcgenex(void)
+int srcgenex_defs(void)
{
return 0;
}
diff --git a/Tests/GeneratorExpression/srcgenex_flags.c b/Tests/GeneratorExpression/srcgenex_flags.c
new file mode 100644
index 0000000..3de2b12
--- /dev/null
+++ b/Tests/GeneratorExpression/srcgenex_flags.c
@@ -0,0 +1,12 @@
+int srcgenex_flags(void)
+{
+ return 0;
+}
+
+int main(int argc, char* argv[])
+{
+#ifndef NAME
+#error NAME not defined
+#endif
+ return NAME();
+}