diff options
author | Marc Chevrier <marc.chevrier@sap.com> | 2017-12-15 11:31:53 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@sap.com> | 2018-01-23 09:24:56 (GMT) |
commit | 78b1c2e09ee5005d75e31c68c1c7b112e4b36d90 (patch) | |
tree | 3df5dc8f66711170a2cd8e0da75adeb7b79102b9 /Tests/GeneratorExpression | |
parent | 3f935e690a337a7a692c30d4d14082e08d1bed7c (diff) | |
download | CMake-78b1c2e09ee5005d75e31c68c1c7b112e4b36d90.zip CMake-78b1c2e09ee5005d75e31c68c1c7b112e4b36d90.tar.gz CMake-78b1c2e09ee5005d75e31c68c1c7b112e4b36d90.tar.bz2 |
sourceFile properties: add property COMPILE_OPTIONS
Add the support of per-source property COMPILE_OPTIONS,
including generator expressions support.
Related: #17507
Diffstat (limited to 'Tests/GeneratorExpression')
-rw-r--r-- | Tests/GeneratorExpression/CMakeLists.txt | 38 | ||||
-rw-r--r-- | Tests/GeneratorExpression/srcgenex.c.in (renamed from Tests/GeneratorExpression/srcgenex_defs.c) | 2 | ||||
-rw-r--r-- | Tests/GeneratorExpression/srcgenex_defs_COMPILE_LANGUAGE.c | 12 | ||||
-rw-r--r-- | Tests/GeneratorExpression/srcgenex_flags.c | 12 | ||||
-rw-r--r-- | Tests/GeneratorExpression/srcgenex_flags_COMPILE_LANGUAGE.c | 12 |
5 files changed, 28 insertions, 48 deletions
diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index 4586357..bc47be7 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -260,17 +260,33 @@ add_custom_target(check-part4 ALL #----------------------------------------------------------------------------- # 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_flags_COMPILE_LANGUAGE srcgenex_flags_COMPILE_LANGUAGE.c) -set_property(SOURCE srcgenex_flags_COMPILE_LANGUAGE.c PROPERTY COMPILE_FLAGS "$<$<COMPILE_LANGUAGE:C>:-DNAME=$<TARGET_PROPERTY:NAME>>") - -add_executable(srcgenex_defs srcgenex_defs.c) -set_property(SOURCE srcgenex_defs.c PROPERTY COMPILE_DEFINITIONS NAME=$<TARGET_PROPERTY:NAME>) - -add_executable(srcgenex_defs_COMPILE_LANGUAGE srcgenex_defs_COMPILE_LANGUAGE.c) -set_property(SOURCE srcgenex_defs_COMPILE_LANGUAGE.c PROPERTY COMPILE_DEFINITIONS $<$<COMPILE_LANGUAGE:C>:NAME=$<TARGET_PROPERTY:NAME>>) +## generate various source files +foreach (item IN ITEMS flags flags_COMPILE_LANGUAGE + options options_COMPILE_LANGUAGE + defs defs_COMPILE_LANGUAGE) + set(TARGET_NAME srcgenex_${item}) + configure_file(srcgenex.c.in ${TARGET_NAME}.c @ONLY) +endforeach() +add_executable(srcgenex_flags "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_flags.c") +set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_flags.c" + PROPERTY COMPILE_FLAGS "-DNAME=$<TARGET_PROPERTY:NAME>") +add_executable(srcgenex_flags_COMPILE_LANGUAGE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_flags_COMPILE_LANGUAGE.c") +set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_flags_COMPILE_LANGUAGE.c" + PROPERTY COMPILE_FLAGS "$<$<COMPILE_LANGUAGE:C>:-DNAME=$<TARGET_PROPERTY:NAME>>") + +add_executable(srcgenex_options "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_options.c") +set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_options.c" + PROPERTY COMPILE_OPTIONS -DUNUSED -DNAME=$<TARGET_PROPERTY:NAME>) +add_executable(srcgenex_options_COMPILE_LANGUAGE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_options_COMPILE_LANGUAGE.c") +set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_options_COMPILE_LANGUAGE.c" + PROPERTY COMPILE_OPTIONS $<$<COMPILE_LANGUAGE:C>:-DNAME=$<TARGET_PROPERTY:NAME>>) + +add_executable(srcgenex_defs "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_defs.c") +set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_defs.c" + PROPERTY COMPILE_DEFINITIONS NAME=$<TARGET_PROPERTY:NAME>) +add_executable(srcgenex_defs_COMPILE_LANGUAGE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_defs_COMPILE_LANGUAGE.c") +set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_defs_COMPILE_LANGUAGE.c" + PROPERTY COMPILE_DEFINITIONS $<$<COMPILE_LANGUAGE:C>:NAME=$<TARGET_PROPERTY:NAME>>) #----------------------------------------------------------------------------- # Cover test properties with generator expressions. diff --git a/Tests/GeneratorExpression/srcgenex_defs.c b/Tests/GeneratorExpression/srcgenex.c.in index 883e631..4a43bd1 100644 --- a/Tests/GeneratorExpression/srcgenex_defs.c +++ b/Tests/GeneratorExpression/srcgenex.c.in @@ -1,4 +1,4 @@ -int srcgenex_defs(void) +int @TARGET_NAME@(void) { return 0; } diff --git a/Tests/GeneratorExpression/srcgenex_defs_COMPILE_LANGUAGE.c b/Tests/GeneratorExpression/srcgenex_defs_COMPILE_LANGUAGE.c deleted file mode 100644 index 421b55b..0000000 --- a/Tests/GeneratorExpression/srcgenex_defs_COMPILE_LANGUAGE.c +++ /dev/null @@ -1,12 +0,0 @@ -int srcgenex_defs_COMPILE_LANGUAGE(void) -{ - return 0; -} - -int main(int argc, char* argv[]) -{ -#ifndef NAME -#error NAME not defined -#endif - return NAME(); -} diff --git a/Tests/GeneratorExpression/srcgenex_flags.c b/Tests/GeneratorExpression/srcgenex_flags.c deleted file mode 100644 index 3de2b12..0000000 --- a/Tests/GeneratorExpression/srcgenex_flags.c +++ /dev/null @@ -1,12 +0,0 @@ -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/GeneratorExpression/srcgenex_flags_COMPILE_LANGUAGE.c b/Tests/GeneratorExpression/srcgenex_flags_COMPILE_LANGUAGE.c deleted file mode 100644 index 4e80d6e..0000000 --- a/Tests/GeneratorExpression/srcgenex_flags_COMPILE_LANGUAGE.c +++ /dev/null @@ -1,12 +0,0 @@ -int srcgenex_flags_COMPILE_LANGUAGE(void) -{ - return 0; -} - -int main(int argc, char* argv[]) -{ -#ifndef NAME -#error NAME not defined -#endif - return NAME(); -} |