diff options
author | Stephen Kelly <steveire@gmail.com> | 2012-11-02 14:47:40 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-10-07 23:56:31 (GMT) |
commit | fe732264e9abb6249d1d112b24ce36b226590105 (patch) | |
tree | 97c08c00ec43b68f692d50729f536d84c7c0d13a /Tests/InterfaceLibrary | |
parent | d4134352abf69374fdad24d53d67734a135daaa5 (diff) | |
download | CMake-fe732264e9abb6249d1d112b24ce36b226590105.zip CMake-fe732264e9abb6249d1d112b24ce36b226590105.tar.gz CMake-fe732264e9abb6249d1d112b24ce36b226590105.tar.bz2 |
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.txt | 15 | ||||
-rw-r--r-- | Tests/InterfaceLibrary/definetestexe.cpp | 9 | ||||
-rw-r--r-- | Tests/InterfaceLibrary/libsdir/CMakeLists.txt | 26 | ||||
-rw-r--r-- | Tests/InterfaceLibrary/libsdir/shareddependlib.cpp | 7 | ||||
-rw-r--r-- | Tests/InterfaceLibrary/libsdir/shareddependlib/shareddependlib.h | 12 | ||||
-rw-r--r-- | Tests/InterfaceLibrary/libsdir/sharedlib.cpp | 12 | ||||
-rw-r--r-- | Tests/InterfaceLibrary/libsdir/sharedlib/sharedlib.h | 15 | ||||
-rw-r--r-- | Tests/InterfaceLibrary/sharedlibtestexe.cpp | 19 |
8 files changed, 115 insertions, 0 deletions
diff --git a/Tests/InterfaceLibrary/CMakeLists.txt b/Tests/InterfaceLibrary/CMakeLists.txt new file mode 100644 index 0000000..53aeb03 --- /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 0000000..decd37c --- /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 0000000..6999646 --- /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 0000000..378ba81 --- /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 0000000..ad9b484 --- /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 0000000..c49ce90 --- /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 0000000..5b3c7db --- /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 0000000..c677f70 --- /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(); +} |