summaryrefslogtreecommitdiffstats
path: root/Tests/CMakeCommands/target_compile_options
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2019-05-29 18:55:18 (GMT)
committerBrad King <brad.king@kitware.com>2019-06-03 14:20:23 (GMT)
commitec66af2026e085e7b648b222794f0f213183ea1e (patch)
tree349db0d7cc51317dce0572bfff44878ec85a39d4 /Tests/CMakeCommands/target_compile_options
parent2d4787fc4ddc077e1d8fcb807768d1ecc7902a73 (diff)
downloadCMake-ec66af2026e085e7b648b222794f0f213183ea1e.zip
CMake-ec66af2026e085e7b648b222794f0f213183ea1e.tar.gz
CMake-ec66af2026e085e7b648b222794f0f213183ea1e.tar.bz2
Genex: CompilerId now can match against a list of ids.
This allows for expressions like: $<$<CXX_COMPILER_ID:Clang,GNU>:-DMY_PRIVATE_DEFINE>
Diffstat (limited to 'Tests/CMakeCommands/target_compile_options')
-rw-r--r--Tests/CMakeCommands/target_compile_options/CMakeLists.txt15
-rw-r--r--Tests/CMakeCommands/target_compile_options/consumer.cpp16
-rw-r--r--Tests/CMakeCommands/target_compile_options/main.cpp12
3 files changed, 41 insertions, 2 deletions
diff --git a/Tests/CMakeCommands/target_compile_options/CMakeLists.txt b/Tests/CMakeCommands/target_compile_options/CMakeLists.txt
index a24cd53..ee187f5 100644
--- a/Tests/CMakeCommands/target_compile_options/CMakeLists.txt
+++ b/Tests/CMakeCommands/target_compile_options/CMakeLists.txt
@@ -7,9 +7,10 @@ add_executable(target_compile_options
"${CMAKE_CURRENT_SOURCE_DIR}/main.cpp"
)
target_compile_options(target_compile_options
- PRIVATE $<$<CXX_COMPILER_ID:GNU>:-DMY_PRIVATE_DEFINE>
+ PRIVATE $<$<CXX_COMPILER_ID:AppleClang,Clang,GNU>:-DMY_PRIVATE_DEFINE>
PUBLIC $<$<COMPILE_LANG_AND_ID:CXX,GNU>:-DMY_PUBLIC_DEFINE>
INTERFACE $<$<CXX_COMPILER_ID:GNU>:-DMY_INTERFACE_DEFINE>
+ INTERFACE $<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-DMY_MULTI_COMP_INTERFACE_DEFINE>
)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
@@ -17,6 +18,11 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
PRIVATE
"DO_GNU_TESTS"
)
+elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ target_compile_definitions(target_compile_options
+ PRIVATE
+ "DO_CLANG_TESTS"
+ )
endif()
add_executable(consumer
@@ -40,7 +46,7 @@ if(CMAKE_GENERATOR MATCHES "Visual Studio")
endif()
target_compile_options(consumer
- PRIVATE $<$<CXX_COMPILER_ID:GNU>:$<TARGET_PROPERTY:target_compile_options,INTERFACE_COMPILE_OPTIONS>>
+ PRIVATE $<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:$<TARGET_PROPERTY:target_compile_options,INTERFACE_COMPILE_OPTIONS>>
)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
@@ -48,6 +54,11 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
PRIVATE
"DO_GNU_TESTS"
)
+elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ target_compile_definitions(consumer
+ PRIVATE
+ "DO_CLANG_TESTS"
+ )
endif()
# Test no items
diff --git a/Tests/CMakeCommands/target_compile_options/consumer.cpp b/Tests/CMakeCommands/target_compile_options/consumer.cpp
index fe79eb5..5cbe049 100644
--- a/Tests/CMakeCommands/target_compile_options/consumer.cpp
+++ b/Tests/CMakeCommands/target_compile_options/consumer.cpp
@@ -13,6 +13,22 @@
# error Expected MY_INTERFACE_DEFINE
# endif
+# ifndef MY_MULTI_COMP_INTERFACE_DEFINE
+# error Expected MY_MULTI_COMP_INTERFACE_DEFINE
+# endif
+
+#endif
+
+#ifdef DO_CLANG_TESTS
+
+# ifdef MY_PRIVATE_DEFINE
+# error Unexpected MY_PRIVATE_DEFINE
+# endif
+
+# ifndef MY_MULTI_COMP_INTERFACE_DEFINE
+# error Expected MY_MULTI_COMP_INTERFACE_DEFINE
+# endif
+
#endif
#ifndef CONSUMER_LANG_CXX
diff --git a/Tests/CMakeCommands/target_compile_options/main.cpp b/Tests/CMakeCommands/target_compile_options/main.cpp
index 829a25e..edefdf2 100644
--- a/Tests/CMakeCommands/target_compile_options/main.cpp
+++ b/Tests/CMakeCommands/target_compile_options/main.cpp
@@ -15,6 +15,18 @@
#endif
+#ifdef DO_CLANG_TESTS
+
+# ifndef MY_PRIVATE_DEFINE
+# error Expected MY_PRIVATE_DEFINE
+# endif
+
+# ifdef MY_PUBLIC_DEFINE
+# error Unexpected MY_PUBLIC_DEFINE
+# endif
+
+#endif
+
int main()
{
return 0;