summaryrefslogtreecommitdiffstats
path: root/Tests/InterfaceLibrary
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-11-03 20:44:32 (GMT)
committerBrad King <brad.king@kitware.com>2016-11-09 14:45:14 (GMT)
commit09cda9d5e7bb31f05177bdaf11d24aeaf85a8dd3 (patch)
treea755fd6424b16a66b008c998e108e7c1b43b64df /Tests/InterfaceLibrary
parent1d1f1eeb6a52d464d476eb0a46eb75c452e3dfbc (diff)
downloadCMake-09cda9d5e7bb31f05177bdaf11d24aeaf85a8dd3.zip
CMake-09cda9d5e7bb31f05177bdaf11d24aeaf85a8dd3.tar.gz
CMake-09cda9d5e7bb31f05177bdaf11d24aeaf85a8dd3.tar.bz2
Allow imported INTERFACE libraries to specify a link library name
Add an `IMPORTED_LIBNAME[_<CONFIG>]` target property to specify a library name to be placed on the link line in place of an interface library since it has no library file of its own. Restrict use of the property to imported `INTERFACE` libraries. This will be particularly useful for find modules that need to provide imported libraries from system SDKs where the full path to the library file is not known. Now such find modules will be able to provide an imported interface library and set `IMPORTED_LIBNAME` to refer to the SDK library by name. Issue: #15267
Diffstat (limited to 'Tests/InterfaceLibrary')
-rw-r--r--Tests/InterfaceLibrary/CMakeLists.txt19
-rw-r--r--Tests/InterfaceLibrary/definetestexe.cpp3
-rw-r--r--Tests/InterfaceLibrary/item.cpp4
-rw-r--r--Tests/InterfaceLibrary/item_fake.cpp5
4 files changed, 29 insertions, 2 deletions
diff --git a/Tests/InterfaceLibrary/CMakeLists.txt b/Tests/InterfaceLibrary/CMakeLists.txt
index ee81419..3db210a 100644
--- a/Tests/InterfaceLibrary/CMakeLists.txt
+++ b/Tests/InterfaceLibrary/CMakeLists.txt
@@ -25,8 +25,25 @@ target_sources(iface_objlib INTERFACE $<TARGET_OBJECTS:objlib>)
add_library(intermediate INTERFACE)
target_link_libraries(intermediate INTERFACE iface_objlib)
+add_library(item_fake_tgt STATIC item_fake.cpp)
+set_property(TARGET item_fake_tgt PROPERTY OUTPUT_NAME item_fake)
+add_library(item_real STATIC item.cpp)
+add_library(item_iface INTERFACE IMPORTED)
+set_property(TARGET item_iface PROPERTY IMPORTED_LIBNAME item_real)
+add_dependencies(item_iface item_real)
+link_directories(${CMAKE_CURRENT_BINARY_DIR})
+
add_executable(InterfaceLibrary definetestexe.cpp)
-target_link_libraries(InterfaceLibrary iface_nodepends headeriface subiface intermediate)
+target_link_libraries(InterfaceLibrary
+ iface_nodepends
+ headeriface
+ subiface
+ intermediate
+
+ item_iface
+ item_fake # ensure that 'item_real' is ordered in place of item_iface
+ )
+add_dependencies(InterfaceLibrary item_fake_tgt)
add_subdirectory(libsdir)
diff --git a/Tests/InterfaceLibrary/definetestexe.cpp b/Tests/InterfaceLibrary/definetestexe.cpp
index a6b5592..098502c 100644
--- a/Tests/InterfaceLibrary/definetestexe.cpp
+++ b/Tests/InterfaceLibrary/definetestexe.cpp
@@ -17,8 +17,9 @@
extern int obj();
extern int sub();
+extern int item();
int main(int, char**)
{
- return obj() + sub();
+ return obj() + sub() + item();
}
diff --git a/Tests/InterfaceLibrary/item.cpp b/Tests/InterfaceLibrary/item.cpp
new file mode 100644
index 0000000..85cda1b
--- /dev/null
+++ b/Tests/InterfaceLibrary/item.cpp
@@ -0,0 +1,4 @@
+int item()
+{
+ return 0;
+}
diff --git a/Tests/InterfaceLibrary/item_fake.cpp b/Tests/InterfaceLibrary/item_fake.cpp
new file mode 100644
index 0000000..b4bd829
--- /dev/null
+++ b/Tests/InterfaceLibrary/item_fake.cpp
@@ -0,0 +1,5 @@
+extern int item_undefined();
+int item()
+{
+ return item_undefined();
+}