diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2020-06-01 17:45:13 (GMT) |
---|---|---|
committer | Robert Maynard <robert.maynard@kitware.com> | 2020-06-09 23:41:20 (GMT) |
commit | 74b1c9fc8e8b33c8faa9aadf6ce09c15d94ea011 (patch) | |
tree | 4574908690751173637e9ef498c495f6a1501e63 /Tests/SetLang | |
parent | 457170a476ca3ff3b5db80360a7fd8202ac31e91 (diff) | |
download | CMake-74b1c9fc8e8b33c8faa9aadf6ce09c15d94ea011.zip CMake-74b1c9fc8e8b33c8faa9aadf6ce09c15d94ea011.tar.gz CMake-74b1c9fc8e8b33c8faa9aadf6ce09c15d94ea011.tar.bz2 |
Explicitly specify language flag when source LANGUAGE property is set
Fixes: #14516, #20716
Diffstat (limited to 'Tests/SetLang')
-rw-r--r-- | Tests/SetLang/CMakeLists.txt | 7 | ||||
-rw-r--r-- | Tests/SetLang/bar.c | 14 | ||||
-rw-r--r-- | Tests/SetLang/zoom.zzz | 7 |
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; +} |