summaryrefslogtreecommitdiffstats
path: root/Tests/ExportImport/Import
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-03-01 14:25:50 (GMT)
committerBrad King <brad.king@kitware.com>2018-03-01 14:28:00 (GMT)
commit7776ce98c3fc1fc656c646ea783c23aee27261a2 (patch)
tree89664e3d07dddfacb10b7b624a2d8a2da7822b08 /Tests/ExportImport/Import
parentbafe655b11c876b45a5ce1fbaf4643593bdd22a3 (diff)
downloadCMake-7776ce98c3fc1fc656c646ea783c23aee27261a2.zip
CMake-7776ce98c3fc1fc656c646ea783c23aee27261a2.tar.gz
CMake-7776ce98c3fc1fc656c646ea783c23aee27261a2.tar.bz2
Tests: Add cases for usage requirements of linked object libs
Add tests to cover transitive usage requirements on installation and export of targets that link to object libraries. Issue: #14778
Diffstat (limited to 'Tests/ExportImport/Import')
-rw-r--r--Tests/ExportImport/Import/A/CMakeLists.txt39
-rw-r--r--Tests/ExportImport/Import/A/imp_testLib9.c16
2 files changed, 43 insertions, 12 deletions
diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt
index 6d16cb7..4e8eac2 100644
--- a/Tests/ExportImport/Import/A/CMakeLists.txt
+++ b/Tests/ExportImport/Import/A/CMakeLists.txt
@@ -231,26 +231,41 @@ target_link_libraries(imp_lib1b bld_testLib2)
if(NOT CMAKE_GENERATOR STREQUAL "Xcode" OR NOT CMAKE_OSX_ARCHITECTURES MATCHES "[;$]")
set(bld_objlib_type OBJECT_LIBRARY)
- # Create a executable that is using objects imported from the install tree
- add_executable(imp_testLib8 imp_testLib8.c $<TARGET_OBJECTS:exp_testLib8>)
+ # Create executables using objects imported from the install tree
+ add_executable(imp_testLib8_src imp_testLib8.c $<TARGET_OBJECTS:exp_testLib8>)
+ add_executable(imp_testLib8_link imp_testLib8.c)
+ target_link_libraries(imp_testLib8_link exp_testLib8)
if(NOT CMAKE_GENERATOR STREQUAL "Xcode" OR NOT XCODE_VERSION VERSION_LESS 5)
- # Create a executable that is using objects imported from the build tree
- add_executable(imp_testLib8b imp_testLib8.c $<TARGET_OBJECTS:bld_testLib8>)
+ # Create executables using objects imported from the build tree
+ add_executable(imp_testLib8b_src imp_testLib8.c $<TARGET_OBJECTS:bld_testLib8>)
+ add_executable(imp_testLib8b_link imp_testLib8.c)
+ target_link_libraries(imp_testLib8b_link bld_testLib8)
endif()
else()
set(bld_objlib_type INTERFACE_LIBRARY)
endif()
+# Create an executable that uses a library imported from the install tree
+# that itself was built using an object library. Verify we get the usage
+# requirements.
+add_executable(imp_testLib9 imp_testLib9.c)
+target_link_libraries(imp_testLib9 exp_testLib9)
+# Similarly for importing from the build tree.
+add_executable(imp_testLib9b imp_testLib9.c)
+target_link_libraries(imp_testLib9b bld_testLib9)
+
# Check that object libraries were transformed on export as expected.
-get_property(type TARGET exp_testLib9Obj PROPERTY TYPE)
-if(NOT type STREQUAL INTERFACE_LIBRARY)
- message(FATAL_ERROR "exp_testLib9Obj type is '${type}', not 'INTERFACE_LIBRARY'")
-endif()
-get_property(type TARGET bld_testLib9Obj PROPERTY TYPE)
-if(NOT type STREQUAL "${bld_objlib_type}")
- message(FATAL_ERROR "bld_testLib9Obj type is '${type}', not '${bld_objlib_type}'")
-endif()
+foreach(vis Pub Priv Iface)
+ get_property(type TARGET exp_testLib9Obj${vis} PROPERTY TYPE)
+ if(NOT type STREQUAL INTERFACE_LIBRARY)
+ message(FATAL_ERROR "exp_testLib9Obj${vis} type is '${type}', not 'INTERFACE_LIBRARY'")
+ endif()
+ get_property(type TARGET bld_testLib9Obj${vis} PROPERTY TYPE)
+ if(NOT type STREQUAL "${bld_objlib_type}")
+ message(FATAL_ERROR "bld_testLib9Obj${vis} type is '${type}', not '${bld_objlib_type}'")
+ endif()
+endforeach()
#-----------------------------------------------------------------------------
# Test that handling imported targets, including transitive dependencies,
diff --git a/Tests/ExportImport/Import/A/imp_testLib9.c b/Tests/ExportImport/Import/A/imp_testLib9.c
new file mode 100644
index 0000000..f9c05fd
--- /dev/null
+++ b/Tests/ExportImport/Import/A/imp_testLib9.c
@@ -0,0 +1,16 @@
+#ifndef testLib9ObjPub_USED
+#error "testLib9ObjPub_USED not defined!"
+#endif
+#ifdef testLib9ObjPriv_USED
+#error "testLib9ObjPriv_USED defined but should not be!"
+#endif
+#ifndef testLib9ObjIface_USED
+#error "testLib9ObjIface_USED not defined!"
+#endif
+
+int testLib9(void);
+
+int main()
+{
+ return testLib9();
+}