summaryrefslogtreecommitdiffstats
path: root/Tests/ExportImport
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-08-19 09:57:13 (GMT)
committerBrad King <brad.king@kitware.com>2013-08-26 15:36:57 (GMT)
commitfd4fb9ef040dde7961500e2241b43909a9e6b1a4 (patch)
treeaa25cb1ed0b9645b185dcc10e3f18d4ca596aff1 /Tests/ExportImport
parentd7c9d60d9fa552a22944d9a912dd61539e012102 (diff)
downloadCMake-fd4fb9ef040dde7961500e2241b43909a9e6b1a4.zip
CMake-fd4fb9ef040dde7961500e2241b43909a9e6b1a4.tar.gz
CMake-fd4fb9ef040dde7961500e2241b43909a9e6b1a4.tar.bz2
try_compile: Extract IMPORTED targets from LINK_DEPENDENT_LIBRARIES
Diffstat (limited to 'Tests/ExportImport')
-rw-r--r--Tests/ExportImport/Export/CMakeLists.txt16
-rw-r--r--Tests/ExportImport/Export/testSharedLibRequiredUser.cpp10
-rw-r--r--Tests/ExportImport/Export/testSharedLibRequiredUser.h12
-rw-r--r--Tests/ExportImport/Import/try_compile/CMakeLists.txt12
4 files changed, 43 insertions, 7 deletions
diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt
index b5b2027..fb2ca86 100644
--- a/Tests/ExportImport/Export/CMakeLists.txt
+++ b/Tests/ExportImport/Export/CMakeLists.txt
@@ -213,6 +213,19 @@ set_property(TARGET testSharedLibRequired APPEND PROPERTY
$<$<CXX_COMPILER_ID:GNU>:-DCUSTOM_COMPILE_OPTION>
)
+add_library(testSharedLibRequiredUser SHARED testSharedLibRequiredUser.cpp)
+generate_export_header(testSharedLibRequiredUser)
+# LINK_PRIVATE so that it appears in the LINK_DEPENDENT_LIBRARIES, but not
+# the INTERFACE_LINK_LIBRARIES.
+set_property(TARGET testSharedLibRequiredUser APPEND PROPERTY
+ INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}>"
+)
+target_link_libraries(testSharedLibRequiredUser LINK_PRIVATE testSharedLibRequired)
+install(FILES
+ "${CMAKE_CURRENT_SOURCE_DIR}/testSharedLibRequiredUser.h"
+ "${CMAKE_CURRENT_BINARY_DIR}/testsharedlibrequireduser_export.h"
+ DESTINATION include/testSharedLibRequiredUser
+)
add_library(testSharedLibDepends SHARED testSharedLibDepends.cpp)
set_property(TARGET testSharedLibDepends APPEND PROPERTY
@@ -284,6 +297,7 @@ install(TARGETS
testLibIncludeRequired5
testLibIncludeRequired6
testSharedLibRequired
+ testSharedLibRequiredUser
noIncludesInterface
EXPORT RequiredExp DESTINATION lib
INCLUDES DESTINATION
@@ -384,7 +398,7 @@ add_subdirectory(sublib) # For CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE test.
# Export from build tree.
export(TARGETS testExe1 testLib1 testLib2 testLib3
testExe2libImp testLib3Imp testLib3ImpDep subdirlib
- testSharedLibRequired testSharedLibDepends renamed_on_export
+ testSharedLibRequired testSharedLibRequiredUser testSharedLibDepends renamed_on_export
cmp0022NEW cmp0022OLD
NAMESPACE bld_
FILE ExportBuildTree.cmake
diff --git a/Tests/ExportImport/Export/testSharedLibRequiredUser.cpp b/Tests/ExportImport/Export/testSharedLibRequiredUser.cpp
new file mode 100644
index 0000000..5580005
--- /dev/null
+++ b/Tests/ExportImport/Export/testSharedLibRequiredUser.cpp
@@ -0,0 +1,10 @@
+
+#include "testSharedLibRequiredUser.h"
+
+#include "testSharedLibRequired.h"
+
+int TestSharedLibRequiredUser::foo()
+{
+ TestSharedLibRequired req;
+ return req.foo();
+}
diff --git a/Tests/ExportImport/Export/testSharedLibRequiredUser.h b/Tests/ExportImport/Export/testSharedLibRequiredUser.h
new file mode 100644
index 0000000..58bcaa5
--- /dev/null
+++ b/Tests/ExportImport/Export/testSharedLibRequiredUser.h
@@ -0,0 +1,12 @@
+
+#ifndef TESTSHAREDLIBREQUIREDUSER_H
+#define TESTSHAREDLIBREQUIREDUSER_H
+
+#include "testsharedlibrequireduser_export.h"
+
+struct TESTSHAREDLIBREQUIREDUSER_EXPORT TestSharedLibRequiredUser
+{
+ int foo();
+};
+
+#endif
diff --git a/Tests/ExportImport/Import/try_compile/CMakeLists.txt b/Tests/ExportImport/Import/try_compile/CMakeLists.txt
index 5600dff..0e57c17 100644
--- a/Tests/ExportImport/Import/try_compile/CMakeLists.txt
+++ b/Tests/ExportImport/Import/try_compile/CMakeLists.txt
@@ -5,17 +5,17 @@ find_package(testLibRequired 2.5 REQUIRED)
include(CheckCXXSourceCompiles)
-set(CMAKE_REQUIRED_LIBRARIES Req::testSharedLibRequired)
+set(CMAKE_REQUIRED_LIBRARIES Req::testSharedLibRequiredUser)
check_cxx_source_compiles(
"
-#include \"testSharedLibRequired.h\"
+#include \"testSharedLibRequiredUser.h\"
int main(int argc, char **argv)
{
- TestSharedLibRequired req;
- return req.foo();
+ TestSharedLibRequiredUser user;
+ return user.foo();
}
-" SHARED_LIB_REQUIRED)
+" SHARED_LIB_DEPENDS)
-if(NOT SHARED_LIB_REQUIRED)
+if(NOT SHARED_LIB_DEPENDS)
message(SEND_ERROR "try_compile with IMPORTED targets failed!\n\n${OUTPUT}")
endif()