summaryrefslogtreecommitdiff
path: root/Tests/InterfaceLibrary
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2012-11-02 15:47:40 +0100
committerBrad King <brad.king@kitware.com>2013-10-07 19:56:31 -0400
commitfe732264e9abb6249d1d112b24ce36b226590105 (patch)
tree97c08c00ec43b68f692d50729f536d84c7c0d13a /Tests/InterfaceLibrary
parentd4134352abf69374fdad24d53d67734a135daaa5 (diff)
downloadcmake-fe732264e9abb6249d1d112b24ce36b226590105.tar.gz
Add the INTERFACE_LIBRARY target type.
This target type only contains INTERFACE_* properties, so it can be used as a structural node. The target-specific commands enforce that they may only be used with the INTERFACE keyword when used with INTERFACE_LIBRARY targets. The old-style target properties matching LINK_INTERFACE_LIBRARIES_<CONFIG> are always ignored for this target type. The name of the INTERFACE_LIBRARY must match a validity generator expression. The validity is similar to that of an ALIAS target, but with the additional restriction that it may not contain double colons. Double colons will carry the meaning of IMPORTED or ALIAS targets in CMake 2.8.13. An ALIAS target may be created for an INTERFACE library. At this point it can not be exported and does not appear in the buildsystem and project files are not created for them. That may be added as a feature in a later commit. The generators need some changes to handle the INTERFACE_LIBRARY targets returned by cmComputeLinkInterface::GetItems. The Ninja generator does not use that API, so it doesn't require changes related to that.
Diffstat (limited to 'Tests/InterfaceLibrary')
-rw-r--r--Tests/InterfaceLibrary/CMakeLists.txt15
-rw-r--r--Tests/InterfaceLibrary/definetestexe.cpp9
-rw-r--r--Tests/InterfaceLibrary/libsdir/CMakeLists.txt26
-rw-r--r--Tests/InterfaceLibrary/libsdir/shareddependlib.cpp7
-rw-r--r--Tests/InterfaceLibrary/libsdir/shareddependlib/shareddependlib.h12
-rw-r--r--Tests/InterfaceLibrary/libsdir/sharedlib.cpp12
-rw-r--r--Tests/InterfaceLibrary/libsdir/sharedlib/sharedlib.h15
-rw-r--r--Tests/InterfaceLibrary/sharedlibtestexe.cpp19
8 files changed, 115 insertions, 0 deletions
diff --git a/Tests/InterfaceLibrary/CMakeLists.txt b/Tests/InterfaceLibrary/CMakeLists.txt
new file mode 100644
index 0000000000..53aeb036b0
--- /dev/null
+++ b/Tests/InterfaceLibrary/CMakeLists.txt
@@ -0,0 +1,15 @@
+
+cmake_minimum_required(VERSION 2.8)
+
+project(InterfaceLibrary)
+
+add_library(iface_nodepends INTERFACE)
+target_compile_definitions(iface_nodepends INTERFACE IFACE_DEFINE)
+
+add_executable(InterfaceLibrary definetestexe.cpp)
+target_link_libraries(InterfaceLibrary iface_nodepends)
+
+add_subdirectory(libsdir)
+
+add_executable(sharedlibtestexe sharedlibtestexe.cpp)
+target_link_libraries(sharedlibtestexe shared_iface)
diff --git a/Tests/InterfaceLibrary/definetestexe.cpp b/Tests/InterfaceLibrary/definetestexe.cpp
new file mode 100644
index 0000000000..decd37c51d
--- /dev/null
+++ b/Tests/InterfaceLibrary/definetestexe.cpp
@@ -0,0 +1,9 @@
+
+#ifndef IFACE_DEFINE
+#error Expected IFACE_DEFINE
+#endif
+
+int main(int,char**)
+{
+ return 0;
+}
diff --git a/Tests/InterfaceLibrary/libsdir/CMakeLists.txt b/Tests/InterfaceLibrary/libsdir/CMakeLists.txt
new file mode 100644
index 0000000000..6999646561
--- /dev/null
+++ b/Tests/InterfaceLibrary/libsdir/CMakeLists.txt
@@ -0,0 +1,26 @@
+
+include(GenerateExportHeader)
+
+add_library(sharedlib SHARED sharedlib.cpp)
+generate_export_header(sharedlib)
+
+add_library(shareddependlib SHARED shareddependlib.cpp)
+generate_export_header(shareddependlib)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
+
+target_link_libraries(sharedlib PUBLIC shareddependlib)
+
+target_include_directories(shareddependlib
+ PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/shareddependlib")
+target_compile_definitions(shareddependlib
+ INTERFACE $<1:SHAREDDEPENDLIB_DEFINE>)
+
+target_include_directories(sharedlib
+ PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/sharedlib")
+target_compile_definitions(shareddependlib
+ INTERFACE $<1:SHAREDLIB_DEFINE>)
+
+add_library(shared_iface INTERFACE)
+target_link_libraries(shared_iface INTERFACE sharedlib)
diff --git a/Tests/InterfaceLibrary/libsdir/shareddependlib.cpp b/Tests/InterfaceLibrary/libsdir/shareddependlib.cpp
new file mode 100644
index 0000000000..378ba8165f
--- /dev/null
+++ b/Tests/InterfaceLibrary/libsdir/shareddependlib.cpp
@@ -0,0 +1,7 @@
+
+#include "shareddependlib.h"
+
+int SharedDependLibObject::foo() const
+{
+ return 0;
+}
diff --git a/Tests/InterfaceLibrary/libsdir/shareddependlib/shareddependlib.h b/Tests/InterfaceLibrary/libsdir/shareddependlib/shareddependlib.h
new file mode 100644
index 0000000000..ad9b484b7a
--- /dev/null
+++ b/Tests/InterfaceLibrary/libsdir/shareddependlib/shareddependlib.h
@@ -0,0 +1,12 @@
+
+#ifndef SHAREDDEPENDLIB_H
+#define SHAREDDEPENDLIB_H
+
+#include "shareddependlib_export.h"
+
+struct SHAREDDEPENDLIB_EXPORT SharedDependLibObject
+{
+ int foo() const;
+};
+
+#endif
diff --git a/Tests/InterfaceLibrary/libsdir/sharedlib.cpp b/Tests/InterfaceLibrary/libsdir/sharedlib.cpp
new file mode 100644
index 0000000000..c49ce905b1
--- /dev/null
+++ b/Tests/InterfaceLibrary/libsdir/sharedlib.cpp
@@ -0,0 +1,12 @@
+
+#include "sharedlib.h"
+
+SharedDependLibObject SharedLibObject::object() const
+{
+ SharedDependLibObject sdlo;
+ return sdlo;
+}
+int SharedLibObject::foo() const
+{
+ return 0;
+}
diff --git a/Tests/InterfaceLibrary/libsdir/sharedlib/sharedlib.h b/Tests/InterfaceLibrary/libsdir/sharedlib/sharedlib.h
new file mode 100644
index 0000000000..5b3c7db732
--- /dev/null
+++ b/Tests/InterfaceLibrary/libsdir/sharedlib/sharedlib.h
@@ -0,0 +1,15 @@
+
+#ifndef SHAREDLIB_H
+#define SHAREDLIB_H
+
+#include "sharedlib_export.h"
+
+#include "shareddependlib.h"
+
+struct SHAREDLIB_EXPORT SharedLibObject
+{
+ SharedDependLibObject object() const;
+ int foo() const;
+};
+
+#endif
diff --git a/Tests/InterfaceLibrary/sharedlibtestexe.cpp b/Tests/InterfaceLibrary/sharedlibtestexe.cpp
new file mode 100644
index 0000000000..c677f7067a
--- /dev/null
+++ b/Tests/InterfaceLibrary/sharedlibtestexe.cpp
@@ -0,0 +1,19 @@
+
+#ifndef SHAREDLIB_DEFINE
+#error Expected SHAREDLIB_DEFINE
+#endif
+
+#ifndef SHAREDDEPENDLIB_DEFINE
+#error Expected SHAREDDEPENDLIB_DEFINE
+#endif
+
+#include "sharedlib.h"
+#include "shareddependlib.h"
+
+int main(int,char**)
+{
+ SharedLibObject sl;
+ SharedDependLibObject sdl = sl.object();
+
+ return sdl.foo() + sl.foo();
+}