summaryrefslogtreecommitdiff
path: root/Tests/ExportImport/Import
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/ExportImport/Import')
-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
5 files changed, 137 insertions, 2 deletions
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()