summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-06-11 11:47:22 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-06-11 11:47:30 (GMT)
commit7925279c20754113227202848545804cde30a3b6 (patch)
treeb75b99ea7e7967316504507da253526c9971d9c8 /Tests
parentd264270307872ca9c7ea0ea4a02ebc300ef86492 (diff)
parent74b1c9fc8e8b33c8faa9aadf6ce09c15d94ea011 (diff)
downloadCMake-7925279c20754113227202848545804cde30a3b6.zip
CMake-7925279c20754113227202848545804cde30a3b6.tar.gz
CMake-7925279c20754113227202848545804cde30a3b6.tar.bz2
Merge topic 'add_explicit_lang_flag_to_compile_object_rule'
74b1c9fc8e Explicitly specify language flag when source LANGUAGE property is set 457170a476 CXX: Compile when possible with explicit `Cxx` language flag set 644d3b86eb C: Compile when possible with explicit `C` language flag set Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4780
Diffstat (limited to 'Tests')
-rw-r--r--Tests/SetLang/CMakeLists.txt7
-rw-r--r--Tests/SetLang/bar.c14
-rw-r--r--Tests/SetLang/zoom.zzz7
3 files changed, 27 insertions, 1 deletions
diff --git a/Tests/SetLang/CMakeLists.txt b/Tests/SetLang/CMakeLists.txt
index f24e5cb..af90f11 100644
--- a/Tests/SetLang/CMakeLists.txt
+++ b/Tests/SetLang/CMakeLists.txt
@@ -8,3 +8,10 @@ add_executable(SetLang bar.c)
set_source_files_properties(foo.c bar.c PROPERTIES LANGUAGE CXX)
target_link_libraries(SetLang foo)
set_target_properties(SetLang PROPERTIES LINKER_LANGUAGE CXX)
+
+if((CMAKE_C_COMPILER_ID MATCHES "(GNU|Clang|MSVC|Borland|Embarcadero|Intel|TI|XL)"))
+ add_library(zoom zoom.zzz)
+ set_source_files_properties(zoom.zzz PROPERTIES LANGUAGE CXX)
+ target_link_libraries(SetLang zoom)
+ target_compile_definitions(SetLang PRIVATE WITH_ZOOM)
+endif()
diff --git a/Tests/SetLang/bar.c b/Tests/SetLang/bar.c
index b934356..515e8c2 100644
--- a/Tests/SetLang/bar.c
+++ b/Tests/SetLang/bar.c
@@ -1,10 +1,22 @@
#include <stdio.h>
int foo();
+
+#ifdef WITH_ZOOM
+int zoom();
+#endif
+
class A
{
public:
- A() { this->i = foo(); }
+ A()
+ {
+ this->i = foo();
+#ifdef WITH_ZOOM
+ i += zoom();
+ i -= zoom();
+#endif
+ }
int i;
};
diff --git a/Tests/SetLang/zoom.zzz b/Tests/SetLang/zoom.zzz
new file mode 100644
index 0000000..a0c8899
--- /dev/null
+++ b/Tests/SetLang/zoom.zzz
@@ -0,0 +1,7 @@
+int zoom()
+{
+ int r = 10;
+ r++;
+ int ret = r + 10;
+ return ret;
+}