diff options
author | Brad King <brad.king@kitware.com> | 2009-07-10 13:53:38 -0400 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-07-10 13:53:38 -0400 |
commit | 22b96543e5a283990d3b41d740b281597b2617af (patch) | |
tree | 241ad925bdd6e9b06ce979b6da79a4ac99daa991 /Tests/LinkLanguage | |
parent | 19792bf30e0499cc49ee518e42274ef02e91db9a (diff) | |
download | cmake-22b96543e5a283990d3b41d740b281597b2617af.tar.gz |
ENH: Test transitive link languages
This test creates a C executable that links to a C++ static library. On
most platforms the executable will not link unless the C++ linker is
chosen correctly.
Diffstat (limited to 'Tests/LinkLanguage')
-rw-r--r-- | Tests/LinkLanguage/CMakeLists.txt | 10 | ||||
-rw-r--r-- | Tests/LinkLanguage/LinkLanguage.c | 6 | ||||
-rw-r--r-- | Tests/LinkLanguage/foo.cxx | 6 |
3 files changed, 22 insertions, 0 deletions
diff --git a/Tests/LinkLanguage/CMakeLists.txt b/Tests/LinkLanguage/CMakeLists.txt new file mode 100644 index 0000000000..89c2982343 --- /dev/null +++ b/Tests/LinkLanguage/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 2.7.20090708) +project(LinkLanguage C CXX) + +add_library(foo STATIC foo.cxx) +add_executable(LinkLanguage LinkLanguage.c) +target_link_libraries(LinkLanguage foo) + +# CMake should now automatically choose CXX for linking, so we need +# not set the property: +#set_property(TARGET LinkLanguage PROPERTY LINKER_LANGUAGE CXX) diff --git a/Tests/LinkLanguage/LinkLanguage.c b/Tests/LinkLanguage/LinkLanguage.c new file mode 100644 index 0000000000..cf1557cabe --- /dev/null +++ b/Tests/LinkLanguage/LinkLanguage.c @@ -0,0 +1,6 @@ +extern int foo(void); +int main() +{ + return foo(); +} + diff --git a/Tests/LinkLanguage/foo.cxx b/Tests/LinkLanguage/foo.cxx new file mode 100644 index 0000000000..5321c2dc0f --- /dev/null +++ b/Tests/LinkLanguage/foo.cxx @@ -0,0 +1,6 @@ +extern "C" int foo(void) +{ + // Reference C++ standard library symbols. + delete new int; + return 0; +} |