Tests: Test using objects from a language enabled in a subdirectory (#15325)
Add a test case that enables CXX in the top level and C in a subdirectory. Create an executable in the top level that uses C objects compiled in the subdirectory. Strictly speaking this is not defined behavior for all language combinations, but happens to work in this case. Test this behavior since projects might try to use it.
This commit is contained in:
parent
fdbfcfdf01
commit
07fc7b75ef
|
@ -255,6 +255,7 @@ if(BUILD_TESTING)
|
|||
endif()
|
||||
ADD_TEST_MACRO(COnly COnly)
|
||||
ADD_TEST_MACRO(CxxOnly CxxOnly)
|
||||
ADD_TEST_MACRO(CxxSubdirC CxxSubdirC)
|
||||
ADD_TEST_MACRO(IPO COnly/COnly)
|
||||
ADD_TEST_MACRO(OutDir runtime/OutDir)
|
||||
ADD_TEST_MACRO(ObjectLibrary UseCshared)
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
cmake_minimum_required(VERSION 3.0)
|
||||
project(CxxSubdirC CXX)
|
||||
add_subdirectory(Cdir)
|
||||
add_executable(CxxSubdirC main.cxx $<TARGET_OBJECTS:Cobj>)
|
|
@ -0,0 +1,2 @@
|
|||
enable_language(C)
|
||||
add_library(Cobj OBJECT Cobj.c)
|
|
@ -0,0 +1 @@
|
|||
int Cobj(void) { return 0; }
|
|
@ -0,0 +1,2 @@
|
|||
extern "C" int Cobj(void);
|
||||
int main() { return Cobj(); }
|
Loading…
Reference in New Issue