diff options
author | Brad King <brad.king@kitware.com> | 2017-12-06 13:05:25 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-12-06 13:05:31 (GMT) |
commit | 060cf73ec8c2d5d73d698b1ff547d425d8ec7eb3 (patch) | |
tree | b244f7af1956fef9bea397cbaeb6094f46dca0e9 /Tests | |
parent | 98206571fb68881fe373c040ae703aac318fe6d7 (diff) | |
parent | 9432f686e62082045f53bd0ec8f8911966476df1 (diff) | |
download | CMake-060cf73ec8c2d5d73d698b1ff547d425d8ec7eb3.zip CMake-060cf73ec8c2d5d73d698b1ff547d425d8ec7eb3.tar.gz CMake-060cf73ec8c2d5d73d698b1ff547d425d8ec7eb3.tar.bz2 |
Merge topic 'src-COMPILE_DEFINITIONS-genex'
9432f686 Add generator expression support to per-source COMPILE_DEFINITIONS
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1546
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/GeneratorExpression/CMakeLists.txt | 9 | ||||
-rw-r--r-- | Tests/GeneratorExpression/srcgenex_defs.c (renamed from Tests/GeneratorExpression/srcgenex.c) | 2 | ||||
-rw-r--r-- | Tests/GeneratorExpression/srcgenex_flags.c | 12 | ||||
-rw-r--r-- | Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-stderr.txt | 8 | ||||
-rw-r--r-- | Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/XcodeProject/RunCMakeTest.cmake | 1 |
7 files changed, 33 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(); +} diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-result.txt b/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-stderr.txt b/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-stderr.txt new file mode 100644 index 0000000..46a294d --- /dev/null +++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-stderr.txt @@ -0,0 +1,8 @@ +^CMake Error in CMakeLists.txt: + Xcode does not support per-config per-source COMPILE_DEFINITIONS: + + \$<\$<CONFIG:Debug>:MYDEBUG> + + specified for source: + + .*/Tests/RunCMake/XcodeProject/main.c$ diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions.cmake b/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions.cmake new file mode 100644 index 0000000..f9df55f --- /dev/null +++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions.cmake @@ -0,0 +1,3 @@ +enable_language(C) +add_executable(main main.c) +set_property(SOURCE main.c PROPERTY COMPILE_DEFINITIONS "$<$<CONFIG:Debug>:MYDEBUG>") diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index f730b83..7eb624c 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -19,6 +19,7 @@ if (NOT XCODE_VERSION VERSION_LESS 6) endif() run_cmake(PerConfigPerSourceFlags) +run_cmake(PerConfigPerSourceDefinitions) # Use a single build tree for a few tests without cleaning. |