From 22b96543e5a283990d3b41d740b281597b2617af Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 10 Jul 2009 13:53:38 -0400 Subject: 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. --- Tests/CMakeLists.txt | 1 + Tests/LinkLanguage/CMakeLists.txt | 10 ++++++++++ Tests/LinkLanguage/LinkLanguage.c | 6 ++++++ Tests/LinkLanguage/foo.cxx | 6 ++++++ 4 files changed, 23 insertions(+) create mode 100644 Tests/LinkLanguage/CMakeLists.txt create mode 100644 Tests/LinkLanguage/LinkLanguage.c create mode 100644 Tests/LinkLanguage/foo.cxx diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index cc0013b..83e11e3 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -92,6 +92,7 @@ IF(BUILD_TESTING) ADD_TEST_MACRO(SetLang SetLang) ADD_TEST_MACRO(ExternalOBJ ExternalOBJ) ADD_TEST_MACRO(LoadCommand LoadedCommand) + ADD_TEST_MACRO(LinkLanguage LinkLanguage) ADD_TEST_MACRO(LinkLine LinkLine) ADD_TEST_MACRO(MacroTest miniMacroTest) ADD_TEST_MACRO(FunctionTest miniFunctionTest) diff --git a/Tests/LinkLanguage/CMakeLists.txt b/Tests/LinkLanguage/CMakeLists.txt new file mode 100644 index 0000000..89c2982 --- /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 0000000..cf1557c --- /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 0000000..5321c2d --- /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; +} -- cgit v0.12