summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-12-23 00:55:08 (GMT)
committerBrad King <brad.king@kitware.com>2014-12-23 01:13:40 (GMT)
commit07fc7b75ef981300e7d873091ee90083b18d1c4a (patch)
treec869f64c456c00ccfccf81de7b8baa0e0a081881 /Tests
parentfdbfcfdf0173c34845e495f4c0bd407faafc45b4 (diff)
downloadCMake-07fc7b75ef981300e7d873091ee90083b18d1c4a.zip
CMake-07fc7b75ef981300e7d873091ee90083b18d1c4a.tar.gz
CMake-07fc7b75ef981300e7d873091ee90083b18d1c4a.tar.bz2
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.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLists.txt1
-rw-r--r--Tests/CxxSubdirC/CMakeLists.txt4
-rw-r--r--Tests/CxxSubdirC/Cdir/CMakeLists.txt2
-rw-r--r--Tests/CxxSubdirC/Cdir/Cobj.c1
-rw-r--r--Tests/CxxSubdirC/main.cxx2
5 files changed, 10 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index a9cad14..f654330 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -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)
diff --git a/Tests/CxxSubdirC/CMakeLists.txt b/Tests/CxxSubdirC/CMakeLists.txt
new file mode 100644
index 0000000..52474f8
--- /dev/null
+++ b/Tests/CxxSubdirC/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 3.0)
+project(CxxSubdirC CXX)
+add_subdirectory(Cdir)
+add_executable(CxxSubdirC main.cxx $<TARGET_OBJECTS:Cobj>)
diff --git a/Tests/CxxSubdirC/Cdir/CMakeLists.txt b/Tests/CxxSubdirC/Cdir/CMakeLists.txt
new file mode 100644
index 0000000..08a8757
--- /dev/null
+++ b/Tests/CxxSubdirC/Cdir/CMakeLists.txt
@@ -0,0 +1,2 @@
+enable_language(C)
+add_library(Cobj OBJECT Cobj.c)
diff --git a/Tests/CxxSubdirC/Cdir/Cobj.c b/Tests/CxxSubdirC/Cdir/Cobj.c
new file mode 100644
index 0000000..75a0045
--- /dev/null
+++ b/Tests/CxxSubdirC/Cdir/Cobj.c
@@ -0,0 +1 @@
+int Cobj(void) { return 0; }
diff --git a/Tests/CxxSubdirC/main.cxx b/Tests/CxxSubdirC/main.cxx
new file mode 100644
index 0000000..049220f
--- /dev/null
+++ b/Tests/CxxSubdirC/main.cxx
@@ -0,0 +1,2 @@
+extern "C" int Cobj(void);
+int main() { return Cobj(); }