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:
Brad King 2014-12-22 19:55:08 -05:00
parent fdbfcfdf01
commit 07fc7b75ef
5 changed files with 10 additions and 0 deletions

View File

@ -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)

View File

@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 3.0)
project(CxxSubdirC CXX)
add_subdirectory(Cdir)
add_executable(CxxSubdirC main.cxx $<TARGET_OBJECTS:Cobj>)

View File

@ -0,0 +1,2 @@
enable_language(C)
add_library(Cobj OBJECT Cobj.c)

View File

@ -0,0 +1 @@
int Cobj(void) { return 0; }

View File

@ -0,0 +1,2 @@
extern "C" int Cobj(void);
int main() { return Cobj(); }