summaryrefslogtreecommitdiff
path: root/Tests/ExportImport
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/ExportImport')
-rw-r--r--Tests/ExportImport/CMakeLists.txt8
-rw-r--r--Tests/ExportImport/Export/CMakeLists.txt177
-rw-r--r--Tests/ExportImport/Export/sublib/CMakeLists.txt6
-rw-r--r--Tests/ExportImport/Export/sublib/subdir.cpp7
-rw-r--r--Tests/ExportImport/Export/sublib/subdir.h12
-rw-r--r--Tests/ExportImport/Export/testLibDepends.c16
-rw-r--r--Tests/ExportImport/Export/testSharedLibDepends.cpp8
-rw-r--r--Tests/ExportImport/Export/testSharedLibDepends.h14
-rw-r--r--Tests/ExportImport/Export/testSharedLibRequired.cpp7
-rw-r--r--Tests/ExportImport/Export/testSharedLibRequired.h12
-rw-r--r--Tests/ExportImport/Import/A/CMakeLists.txt51
-rw-r--r--Tests/ExportImport/Import/A/deps_iface.c24
-rw-r--r--Tests/ExportImport/Import/A/deps_shared_iface.cpp41
-rw-r--r--Tests/ExportImport/Import/CMakeLists.txt2
-rw-r--r--Tests/ExportImport/Import/try_compile/CMakeLists.txt21
15 files changed, 396 insertions, 10 deletions
diff --git a/Tests/ExportImport/CMakeLists.txt b/Tests/ExportImport/CMakeLists.txt
index d6593e824..b8368fc98 100644
--- a/Tests/ExportImport/CMakeLists.txt
+++ b/Tests/ExportImport/CMakeLists.txt
@@ -41,9 +41,11 @@ add_custom_command(
--build-project Export
--build-target install
--build-generator ${CMAKE_GENERATOR}
+ --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
--build-options -C${ExportImport_BINARY_DIR}/InitialCache.cmake
- )
+ VERBATIM
+ )
add_custom_target(ExportTarget ALL DEPENDS ${ExportImport_BINARY_DIR}/ExportProject)
add_dependencies(ExportTarget CleanupTarget)
set_property(
@@ -61,9 +63,11 @@ add_custom_command(
--build-noclean
--build-project Import
--build-generator ${CMAKE_GENERATOR}
+ --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
--build-options -C${ExportImport_BINARY_DIR}/InitialCache.cmake
- )
+ VERBATIM
+ )
add_custom_target(ImportTarget ALL DEPENDS ${ExportImport_BINARY_DIR}/ImportProject)
add_dependencies(ImportTarget ExportTarget)
set_property(
diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt
index e19ab88de..be48483da 100644
--- a/Tests/ExportImport/Export/CMakeLists.txt
+++ b/Tests/ExportImport/Export/CMakeLists.txt
@@ -90,14 +90,176 @@ set_property(TARGET testLibCycleA PROPERTY LINK_INTERFACE_MULTIPLICITY 3)
# Test exporting dependent libraries into different exports
add_library(testLibRequired testLibRequired.c)
add_library(testLibDepends testLibDepends.c)
-target_link_libraries(testLibDepends testLibRequired)
+target_link_libraries(testLibDepends LINK_PUBLIC testLibRequired)
-install(TARGETS testLibRequired EXPORT RequiredExp DESTINATION lib )
-install(EXPORT RequiredExp NAMESPACE Req:: FILE testLibRequiredConfig.cmake DESTINATION lib/cmake/testLibRequired)
+macro(add_include_lib _libName)
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_libName}.c" "// no content\n")
+ add_library(${_libName} "${CMAKE_CURRENT_BINARY_DIR}/${_libName}.c")
+ file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${_libName}")
+ set_property(TARGET ${_libName} APPEND PROPERTY
+ INTERFACE_INCLUDE_DIRECTORIES
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/${_libName}>"
+ "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/${_libName}>"
+ )
+ if (NOT "${ARGV1}" STREQUAL "NO_HEADER")
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_libName}/${_libName}.h" "// no content\n")
+ install(FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/${_libName}/${_libName}.h"
+ DESTINATION include/${_libName}
+ )
+ endif()
+endmacro()
-install(TARGETS testLibDepends EXPORT DependsExp DESTINATION lib )
-install(EXPORT DependsExp FILE testLibDependsConfig.cmake DESTINATION lib/cmake/testLibDepends)
+add_include_lib(testLibIncludeRequired1)
+add_include_lib(testLibIncludeRequired2)
+add_include_lib(testLibIncludeRequired3 NO_HEADER)
+# Generate testLibIncludeRequired4 in the testLibIncludeRequired3 directory
+# with an error. If the includes from testLibIncludeRequired3 appear first,
+# the error will be hit.
+# Below, the '3' library appears before the '4' library
+# but we are testing that the INSTALL_INTERFACE causes it not to be used
+# at build time.
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testLibIncludeRequired3/testLibIncludeRequired4.h" "#error Should not be included\n")
+install(FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/testLibIncludeRequired3/testLibIncludeRequired4.h"
+ DESTINATION include/testLibIncludeRequired3
+)
+add_include_lib(testLibIncludeRequired4)
+add_include_lib(testLibIncludeRequired5 NO_HEADER)
+# Generate testLibIncludeRequired6 in the testLibIncludeRequired5 directory
+# with an error. If the includes from testLibIncludeRequired5 appear first,
+# the error will be hit.
+# Below, the '5' library appears before the '6' library
+# but we are testing that when the installed IMPORTED target is used, from
+# the Import side of this unit test, the '6' include from the '5' directory
+# will not be used because it is in the BUILD_INTERFACE only.
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testLibIncludeRequired5/testLibIncludeRequired6.h" "#error Should not be included\n")
+install(FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/testLibIncludeRequired5/testLibIncludeRequired6.h"
+ DESTINATION include/testLibIncludeRequired5
+)
+add_include_lib(testLibIncludeRequired6)
+set_property(TARGET testLibRequired APPEND PROPERTY
+ INTERFACE_INCLUDE_DIRECTORIES
+ $<TARGET_PROPERTY:testLibIncludeRequired1,INTERFACE_INCLUDE_DIRECTORIES>
+ $<TARGET_PROPERTY:$<1:$<TARGET_NAME:testLibIncludeRequired2>>,INTERFACE_INCLUDE_DIRECTORIES>
+ $<INSTALL_INTERFACE:$<TARGET_PROPERTY:testLibIncludeRequired3,INTERFACE_INCLUDE_DIRECTORIES>>
+ $<BUILD_INTERFACE:$<TARGET_PROPERTY:testLibIncludeRequired4,INTERFACE_INCLUDE_DIRECTORIES>>
+ $<BUILD_INTERFACE:$<TARGET_PROPERTY:testLibIncludeRequired5,INTERFACE_INCLUDE_DIRECTORIES>>
+ $<INSTALL_INTERFACE:$<TARGET_PROPERTY:testLibIncludeRequired6,INTERFACE_INCLUDE_DIRECTORIES>>
+ # The BUILD_INTERFACE entry from above is duplicated below. This is to test that
+ # the INSTALL_INTERFACE entry bound by a BUILD_INTERFACE entry on either side is
+ # preprocessed correctly on install(EXPORT).
+ $<BUILD_INTERFACE:$<TARGET_PROPERTY:testLibIncludeRequired5,INTERFACE_INCLUDE_DIRECTORIES>>
+ # Test that the below is non-fatal
+ $<$<STREQUAL:one,two>:$<TARGET_PROPERTY:not_a_target,INTERFACE_INCLUDE_DIRECTORIES>>
+)
+
+set_property(TARGET testLibRequired APPEND PROPERTY
+ INTERFACE_COMPILE_DEFINITIONS
+ testLibRequired_IFACE_DEFINE
+ $<BUILD_INTERFACE:BuildOnly_DEFINE>
+ $<INSTALL_INTERFACE:InstallOnly_DEFINE>
+)
+
+include(GenerateExportHeader)
+
+add_library(testSharedLibRequired SHARED testSharedLibRequired.cpp)
+generate_export_header(testSharedLibRequired)
+set_property(TARGET testSharedLibRequired
+ PROPERTY
+ INTERFACE_POSITION_INDEPENDENT_CODE ON
+)
+set_property(TARGET testSharedLibRequired APPEND PROPERTY
+ INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}"
+)
+install(FILES
+ "${CMAKE_CURRENT_SOURCE_DIR}/testSharedLibRequired.h"
+ "${CMAKE_CURRENT_BINARY_DIR}/testsharedlibrequired_export.h"
+ DESTINATION include/testSharedLibRequired
+)
+set_property(TARGET testSharedLibRequired APPEND PROPERTY
+ INTERFACE_INCLUDE_DIRECTORIES "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/testSharedLibRequired>"
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}>"
+)
+set_property(TARGET testSharedLibRequired
+ APPEND PROPERTY
+ COMPATIBLE_INTERFACE_BOOL CUSTOM_PROP
+)
+set_property(TARGET testSharedLibRequired
+ PROPERTY
+ INTERFACE_CUSTOM_PROP ON
+)
+set_property(TARGET testSharedLibRequired
+ APPEND PROPERTY
+ COMPATIBLE_INTERFACE_STRING CUSTOM_STRING
+)
+set_property(TARGET testSharedLibRequired
+ PROPERTY
+ INTERFACE_CUSTOM_STRING testcontent
+)
+
+add_library(testSharedLibDepends SHARED testSharedLibDepends.cpp)
+set_property(TARGET testSharedLibDepends APPEND PROPERTY
+ INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}"
+)
+generate_export_header(testSharedLibDepends)
+
+set_property(TARGET testSharedLibDepends APPEND PROPERTY
+ INTERFACE_INCLUDE_DIRECTORIES
+ $<TARGET_PROPERTY:testSharedLibRequired,INTERFACE_INCLUDE_DIRECTORIES>
+)
+install(FILES
+ "${CMAKE_CURRENT_SOURCE_DIR}/testSharedLibDepends.h"
+ "${CMAKE_CURRENT_BINARY_DIR}/testsharedlibdepends_export.h"
+ DESTINATION include/testSharedLibDepends
+)
+set_property(TARGET testSharedLibDepends APPEND PROPERTY
+ INTERFACE_INCLUDE_DIRECTORIES "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/testSharedLibDepends>"
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}>"
+)
+set_property(TARGET testSharedLibDepends APPEND PROPERTY
+ LINK_INTERFACE_LIBRARIES
+ $<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:$<TARGET_NAME:testSharedLibRequired>>
+)
+
+# LINK_PRIVATE because the LINK_INTERFACE_LIBRARIES is specified above.
+target_link_libraries(testSharedLibDepends LINK_PRIVATE testSharedLibRequired)
+
+install(TARGETS testLibRequired
+ testLibIncludeRequired1
+ testLibIncludeRequired2
+ testLibIncludeRequired3
+ testLibIncludeRequired4
+ testLibIncludeRequired5
+ testLibIncludeRequired6
+ testSharedLibRequired
+ EXPORT RequiredExp DESTINATION lib )
+install(EXPORT RequiredExp NAMESPACE Req:: FILE testLibRequiredTargets.cmake DESTINATION lib/cmake/testLibRequired)
+
+install(TARGETS testLibDepends testSharedLibDepends EXPORT DependsExp DESTINATION lib )
+install(EXPORT DependsExp FILE testLibDependsTargets.cmake DESTINATION lib/cmake/testLibDepends)
+
+file(WRITE
+ "${CMAKE_CURRENT_BINARY_DIR}/testLibRequiredConfig.cmake"
+ "
+if(\${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION VERSION_LESS 2.3 AND NOT \${CMAKE_FIND_PACKAGE_NAME}_INTERFACES)
+ set(\${CMAKE_FIND_PACKAGE_NAME}_NO_INTERFACES 1)
+endif()
+include(\"\${CMAKE_CURRENT_LIST_DIR}/testLibRequiredTargets.cmake\")
+set(\${CMAKE_FIND_PACKAGE_NAME}_INCLUDE_DIRS \"${CMAKE_CURRENT_BINARY_DIR}\" \"${CMAKE_CURRENT_SOURCE_DIR}\" )
+"
+)
+
+include(CMakePackageConfigHelpers)
+write_basic_package_version_file( testLibRequiredConfigVersion.cmake VERSION 2.5 COMPATIBILITY AnyNewerVersion)
+
+install(FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/testLibRequiredConfig.cmake"
+ "${CMAKE_CURRENT_BINARY_DIR}/testLibRequiredConfigVersion.cmake"
+ DESTINATION lib/cmake/testLibRequired
+)
# Install and export from install tree.
install(
@@ -143,9 +305,12 @@ if(WIN32)
install(TARGETS testLib5 RUNTIME DESTINATION bin)
endif()
+add_subdirectory(sublib) # For CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE test.
+
# Export from build tree.
export(TARGETS testExe1 testLib1 testLib2 testLib3
- testExe2libImp testLib3Imp testLib3ImpDep
+ testExe2libImp testLib3Imp testLib3ImpDep subdirlib
+ testSharedLibRequired testSharedLibDepends
NAMESPACE bld_
FILE ExportBuildTree.cmake
)
diff --git a/Tests/ExportImport/Export/sublib/CMakeLists.txt b/Tests/ExportImport/Export/sublib/CMakeLists.txt
new file mode 100644
index 000000000..a5c6413c1
--- /dev/null
+++ b/Tests/ExportImport/Export/sublib/CMakeLists.txt
@@ -0,0 +1,6 @@
+
+set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+add_library(subdirlib SHARED subdir.cpp)
+generate_export_header(subdirlib)
diff --git a/Tests/ExportImport/Export/sublib/subdir.cpp b/Tests/ExportImport/Export/sublib/subdir.cpp
new file mode 100644
index 000000000..35b074368
--- /dev/null
+++ b/Tests/ExportImport/Export/sublib/subdir.cpp
@@ -0,0 +1,7 @@
+
+#include "subdir.h"
+
+int SubDirObject::foo()
+{
+ return 0;
+}
diff --git a/Tests/ExportImport/Export/sublib/subdir.h b/Tests/ExportImport/Export/sublib/subdir.h
new file mode 100644
index 000000000..3a4b73d73
--- /dev/null
+++ b/Tests/ExportImport/Export/sublib/subdir.h
@@ -0,0 +1,12 @@
+
+#ifndef SUBDIR_H
+#define SUBDIR_H
+
+#include "subdirlib_export.h"
+
+struct SUBDIRLIB_EXPORT SubDirObject
+{
+ int foo();
+};
+
+#endif
diff --git a/Tests/ExportImport/Export/testLibDepends.c b/Tests/ExportImport/Export/testLibDepends.c
index 2849b336d..fb5a002e0 100644
--- a/Tests/ExportImport/Export/testLibDepends.c
+++ b/Tests/ExportImport/Export/testLibDepends.c
@@ -1,4 +1,20 @@
+#include "testLibIncludeRequired1.h"
+#include "testLibIncludeRequired2.h"
+#include "testLibIncludeRequired4.h"
+
+#ifndef testLibRequired_IFACE_DEFINE
+#error Expected testLibRequired_IFACE_DEFINE
+#endif
+
+#ifndef BuildOnly_DEFINE
+#error Expected BuildOnly_DEFINE
+#endif
+
+#ifdef InstallOnly_DEFINE
+#error Unexpected InstallOnly_DEFINE
+#endif
+
extern int testLibRequired(void);
int testLibDepends(void) { return testLibRequired(); }
diff --git a/Tests/ExportImport/Export/testSharedLibDepends.cpp b/Tests/ExportImport/Export/testSharedLibDepends.cpp
new file mode 100644
index 000000000..e27920725
--- /dev/null
+++ b/Tests/ExportImport/Export/testSharedLibDepends.cpp
@@ -0,0 +1,8 @@
+
+#include "testSharedLibDepends.h"
+
+int TestSharedLibDepends::foo()
+{
+ TestSharedLibRequired req;
+ return req.foo();
+}
diff --git a/Tests/ExportImport/Export/testSharedLibDepends.h b/Tests/ExportImport/Export/testSharedLibDepends.h
new file mode 100644
index 000000000..b93143a5c
--- /dev/null
+++ b/Tests/ExportImport/Export/testSharedLibDepends.h
@@ -0,0 +1,14 @@
+
+#ifndef TESTSHAREDLIBDEPENDS_H
+#define TESTSHAREDLIBDEPENDS_H
+
+#include "testsharedlibdepends_export.h"
+
+#include "testSharedLibRequired.h"
+
+struct TESTSHAREDLIBDEPENDS_EXPORT TestSharedLibDepends
+{
+ int foo();
+};
+
+#endif
diff --git a/Tests/ExportImport/Export/testSharedLibRequired.cpp b/Tests/ExportImport/Export/testSharedLibRequired.cpp
new file mode 100644
index 000000000..1ac34aaef
--- /dev/null
+++ b/Tests/ExportImport/Export/testSharedLibRequired.cpp
@@ -0,0 +1,7 @@
+
+#include "testSharedLibRequired.h"
+
+int TestSharedLibRequired::foo()
+{
+ return 0;
+}
diff --git a/Tests/ExportImport/Export/testSharedLibRequired.h b/Tests/ExportImport/Export/testSharedLibRequired.h
new file mode 100644
index 000000000..edaddd485
--- /dev/null
+++ b/Tests/ExportImport/Export/testSharedLibRequired.h
@@ -0,0 +1,12 @@
+
+#ifndef TESTSHAREDLIBREQUIRED_H
+#define TESTSHAREDLIBREQUIRED_H
+
+#include "testsharedlibrequired_export.h"
+
+struct TESTSHAREDLIBREQUIRED_EXPORT TestSharedLibRequired
+{
+ int foo();
+};
+
+#endif
diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt
index 884179225..0337130f4 100644
--- a/Tests/ExportImport/Import/A/CMakeLists.txt
+++ b/Tests/ExportImport/Import/A/CMakeLists.txt
@@ -5,8 +5,8 @@ include(${Import_BINARY_DIR}/../Export/ExportBuildTree.cmake)
include(${CMAKE_INSTALL_PREFIX}/lib/exp/exp.cmake)
# Import two exports, where the Depends one depends on an exported target from the Required one:
-include(${CMAKE_INSTALL_PREFIX}/lib/cmake/testLibRequired/testLibRequiredConfig.cmake)
-include(${CMAKE_INSTALL_PREFIX}/lib/cmake/testLibDepends/testLibDependsConfig.cmake)
+include(${CMAKE_INSTALL_PREFIX}/lib/cmake/testLibRequired/testLibRequiredTargets.cmake)
+include(${CMAKE_INSTALL_PREFIX}/lib/cmake/testLibDepends/testLibDependsTargets.cmake)
# Try referencing an executable imported from the install tree.
add_custom_command(
@@ -152,3 +152,50 @@ check_function_exists(testLib1 HAVE_TESTLIB1_FUNCTION)
if (NOT HAVE_TESTLIB1_FUNCTION)
message(SEND_ERROR "Using imported target testLib2 in check_function_exists() failed !")
endif()
+
+#-----------------------------------------------------------------------------
+# Test that dependent imported targets have usable
+# INTERFACE_COMPILE_DEFINITIONS and INTERFACE_INCLUDE_DIRECTORIES
+
+add_executable(deps_iface deps_iface.c)
+target_link_libraries(deps_iface testLibDepends)
+
+add_executable(deps_shared_iface deps_shared_iface.cpp)
+target_link_libraries(deps_shared_iface testSharedLibDepends)
+target_compile_definitions(deps_shared_iface
+ PRIVATE
+ $<$<BOOL:$<TARGET_PROPERTY:POSITION_INDEPENDENT_CODE>>:PIC_PROPERTY_IS_ON>
+ $<$<BOOL:$<TARGET_PROPERTY:CUSTOM_PROP>>:CUSTOM_PROPERTY_IS_ON>
+ $<$<STREQUAL:$<TARGET_PROPERTY:CUSTOM_STRING>,testcontent>:CUSTOM_STRING_IS_MATCH>
+)
+
+if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+ include(CheckCXXCompilerFlag)
+ check_cxx_compiler_flag(-fPIE run_pic_test)
+else()
+ if (CMAKE_CXX_COMPILER_ID MATCHES "PGI"
+ OR CMAKE_CXX_COMPILER_ID MATCHES "PathScale"
+ OR CMAKE_SYSTEM_NAME MATCHES "IRIX64"
+ OR CMAKE_CXX_COMPILER_ID MATCHES "Intel")
+ set(run_pic_test 0)
+ else()
+ set(run_pic_test 1)
+ endif()
+endif()
+
+if (run_pic_test)
+ target_compile_definitions(deps_shared_iface PRIVATE CHECK_PIC_WORKS)
+endif()
+
+#-----------------------------------------------------------------------------
+# Test that targets imported from the build tree have their dependencies
+# evaluated correctly. The above already tests the same for the install tree.
+
+add_executable(deps_shared_iface2 deps_shared_iface.cpp)
+target_link_libraries(deps_shared_iface2 bld_testSharedLibDepends bld_subdirlib)
+target_compile_definitions(deps_shared_iface2
+ PRIVATE TEST_SUBDIR_LIB
+ $<$<BOOL:$<TARGET_PROPERTY:POSITION_INDEPENDENT_CODE>>:PIC_PROPERTY_IS_ON>
+ $<$<BOOL:$<TARGET_PROPERTY:CUSTOM_PROP>>:CUSTOM_PROPERTY_IS_ON>
+ $<$<STREQUAL:$<TARGET_PROPERTY:CUSTOM_STRING>,testcontent>:CUSTOM_STRING_IS_MATCH>
+)
diff --git a/Tests/ExportImport/Import/A/deps_iface.c b/Tests/ExportImport/Import/A/deps_iface.c
new file mode 100644
index 000000000..e73ca26bf
--- /dev/null
+++ b/Tests/ExportImport/Import/A/deps_iface.c
@@ -0,0 +1,24 @@
+
+#include "testLibIncludeRequired1.h"
+#include "testLibIncludeRequired2.h"
+#include "testLibIncludeRequired6.h"
+
+#ifndef testLibRequired_IFACE_DEFINE
+#error Expected testLibRequired_IFACE_DEFINE
+#endif
+
+#ifdef BuildOnly_DEFINE
+#error Unexpected BuildOnly_DEFINE
+#endif
+
+#ifndef InstallOnly_DEFINE
+#error Expected InstallOnly_DEFINE
+#endif
+
+extern int testLibDepends(void);
+
+
+int main()
+{
+ return testLibDepends();
+}
diff --git a/Tests/ExportImport/Import/A/deps_shared_iface.cpp b/Tests/ExportImport/Import/A/deps_shared_iface.cpp
new file mode 100644
index 000000000..2f0e74a07
--- /dev/null
+++ b/Tests/ExportImport/Import/A/deps_shared_iface.cpp
@@ -0,0 +1,41 @@
+
+
+#include "testSharedLibDepends.h"
+
+#ifdef CHECK_PIC_WORKS
+#if defined(__ELF__) && !defined(__PIC__) && !defined(__PIE__)
+#error Expected by INTERFACE_POSITION_INDEPENDENT_CODE property of dependency
+#endif
+#endif
+
+#ifndef PIC_PROPERTY_IS_ON
+#error Expected PIC_PROPERTY_IS_ON
+#endif
+
+#ifndef CUSTOM_PROPERTY_IS_ON
+#error Expected CUSTOM_PROPERTY_IS_ON
+#endif
+
+#ifndef CUSTOM_STRING_IS_MATCH
+#error Expected CUSTOM_STRING_IS_MATCH
+#endif
+
+#ifdef TEST_SUBDIR_LIB
+#include "subdir.h"
+#endif
+
+int main(int,char **)
+{
+ TestSharedLibDepends dep;
+ TestSharedLibRequired req;
+
+#ifdef TEST_SUBDIR_LIB
+ SubDirObject sdo;
+#endif
+
+ return dep.foo() + req.foo()
+#ifdef TEST_SUBDIR_LIB
+ + sdo.foo()
+#endif
+ ;
+}
diff --git a/Tests/ExportImport/Import/CMakeLists.txt b/Tests/ExportImport/Import/CMakeLists.txt
index 3fc78a280..9c2d5977c 100644
--- a/Tests/ExportImport/Import/CMakeLists.txt
+++ b/Tests/ExportImport/Import/CMakeLists.txt
@@ -17,3 +17,5 @@ add_executable(imp_testTransExe1 imp_testTransExe1.c)
target_link_libraries(imp_testTransExe1 imp_lib1)
add_executable(imp_testTransExe1b imp_testTransExe1.c)
target_link_libraries(imp_testTransExe1b imp_lib1b)
+
+add_subdirectory(try_compile)
diff --git a/Tests/ExportImport/Import/try_compile/CMakeLists.txt b/Tests/ExportImport/Import/try_compile/CMakeLists.txt
new file mode 100644
index 000000000..5600dffdf
--- /dev/null
+++ b/Tests/ExportImport/Import/try_compile/CMakeLists.txt
@@ -0,0 +1,21 @@
+
+cmake_minimum_required(VERSION 2.8)
+
+find_package(testLibRequired 2.5 REQUIRED)
+
+include(CheckCXXSourceCompiles)
+
+set(CMAKE_REQUIRED_LIBRARIES Req::testSharedLibRequired)
+check_cxx_source_compiles(
+ "
+#include \"testSharedLibRequired.h\"
+int main(int argc, char **argv)
+{
+ TestSharedLibRequired req;
+ return req.foo();
+}
+" SHARED_LIB_REQUIRED)
+
+if(NOT SHARED_LIB_REQUIRED)
+ message(SEND_ERROR "try_compile with IMPORTED targets failed!\n\n${OUTPUT}")
+endif()