summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-08-21 20:00:48 (GMT)
committerBrad King <brad.king@kitware.com>2013-10-21 13:46:27 (GMT)
commitb04f3b9a2a116b1956d5342637cda1348a5ee07b (patch)
treeb7235edeb963d70d50711210172a7f3612711142 /Tests
parentdba4962b868c3baa7886dcd3f8b597e971a479a2 (diff)
downloadCMake-b04f3b9a2a116b1956d5342637cda1348a5ee07b.zip
CMake-b04f3b9a2a116b1956d5342637cda1348a5ee07b.tar.gz
CMake-b04f3b9a2a116b1956d5342637cda1348a5ee07b.tar.bz2
Create make rules for INTERFACE_LIBRARY targets.
The result is that the depends of the target are created. So, add_library(somelib foo.cpp) add_library(anotherlib EXCLUDE_FROM_ALL foo.cpp) add_library(extra EXCLUDE_FROM_ALL foo.cpp) target_link_libraries(anotherlib extra) add_library(iface INTERFACE) target_link_libraries(iface INTERFACE anotherlib) Executing 'make iface' will result in the anotherlib and extra targets being made. Adding a regular executable to the INTERFACE of an INTERFACE_LIBRARY will not result in the executable being built with 'make iface' because of the logic in cmComputeTargetDepends::AddTargetDepend. So far, this is implemented only for the Makefile generator. Other generators will follow if this feature is possible for them. Make INTERFACE_LIBRARY targets part of the all target by default. Test this by building the all target and making the expected library EXCLUDE_FROM_ALL.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLists.txt17
-rw-r--r--Tests/InterfaceBuildTargets/CMakeLists.txt13
-rw-r--r--Tests/InterfaceBuildTargets/main.cxx5
-rw-r--r--Tests/InterfaceBuildTargets/testlib.cxx5
4 files changed, 40 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 2f6a456..198ce04 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -261,6 +261,23 @@ if(BUILD_TESTING)
PASS_REGULAR_EXPRESSION "(file is not of required architecture|does not match cputype|not the architecture being linked)")
endif()
+ if(CMAKE_TEST_GENERATOR MATCHES Make)
+ set(InterfaceBuildTargets_libname testlib)
+ if (CMAKE_TEST_GENERATOR MATCHES "Borland|Watcom")
+ set(InterfaceBuildTargets_libname testlib.lib)
+ endif()
+ add_test(InterfaceBuildTargets ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/InterfaceBuildTargets"
+ "${CMake_BINARY_DIR}/Tests/InterfaceBuildTargets"
+ --build-two-config
+ ${build_generator_args}
+ --build-project InterfaceBuildTargets
+ --test-command ${CMAKE_CMAKE_COMMAND} -E touch_nocreate ${InterfaceBuildTargets_libname}
+ )
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/InterfaceBuildTargets")
+ endif()
+
list(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX})
if(NOT QT4_FOUND)
diff --git a/Tests/InterfaceBuildTargets/CMakeLists.txt b/Tests/InterfaceBuildTargets/CMakeLists.txt
new file mode 100644
index 0000000..a00e5d5
--- /dev/null
+++ b/Tests/InterfaceBuildTargets/CMakeLists.txt
@@ -0,0 +1,13 @@
+project(InterfaceBuildTargets)
+
+add_library(testlib EXCLUDE_FROM_ALL testlib.cxx)
+set_property(TARGET testlib PROPERTY PREFIX "")
+if(CMAKE_GENERATOR MATCHES "Borland|Watcom")
+ # These librarians add the .lib suffix anyway.
+ set_property(TARGET testlib PROPERTY SUFFIX ".lib")
+else()
+ set_property(TARGET testlib PROPERTY SUFFIX "")
+endif()
+
+add_library(iface INTERFACE)
+target_link_libraries(iface INTERFACE testlib)
diff --git a/Tests/InterfaceBuildTargets/main.cxx b/Tests/InterfaceBuildTargets/main.cxx
new file mode 100644
index 0000000..e9ad257
--- /dev/null
+++ b/Tests/InterfaceBuildTargets/main.cxx
@@ -0,0 +1,5 @@
+
+int main(int, char**)
+{
+ return 0;
+}
diff --git a/Tests/InterfaceBuildTargets/testlib.cxx b/Tests/InterfaceBuildTargets/testlib.cxx
new file mode 100644
index 0000000..02bd6b0
--- /dev/null
+++ b/Tests/InterfaceBuildTargets/testlib.cxx
@@ -0,0 +1,5 @@
+
+void testlib(void)
+{
+
+}