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.
This commit is contained in:
parent
19792bf30e
commit
22b96543e5
|
@ -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)
|
||||
|
|
|
@ -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)
|
|
@ -0,0 +1,6 @@
|
|||
extern int foo(void);
|
||||
int main()
|
||||
{
|
||||
return foo();
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
extern "C" int foo(void)
|
||||
{
|
||||
// Reference C++ standard library symbols.
|
||||
delete new int;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue