From 955b96629e05bf2ddb6c94fa7a130e2b5b744782 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sun, 23 Sep 2012 19:19:55 +0200 Subject: [PATCH] exports: add a test for exporting dependent targets The test exports two libraries into two separate exports, and then include()s the generated export files. This must not fail. Alex --- Tests/ExportImport/Export/CMakeLists.txt | 12 ++++++++++++ Tests/ExportImport/Export/testLibDepends.c | 4 ++++ Tests/ExportImport/Export/testLibRequired.c | 1 + Tests/ExportImport/Import/A/CMakeLists.txt | 4 ++++ 4 files changed, 21 insertions(+) create mode 100644 Tests/ExportImport/Export/testLibDepends.c create mode 100644 Tests/ExportImport/Export/testLibRequired.c diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index f118c30de..e19ab88de 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -87,6 +87,18 @@ target_link_libraries(testLibCycleA testLibCycleB) target_link_libraries(testLibCycleB testLibCycleA) 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) + +install(TARGETS testLibRequired EXPORT RequiredExp DESTINATION lib ) +install(EXPORT RequiredExp NAMESPACE Req:: FILE testLibRequiredConfig.cmake DESTINATION lib/cmake/testLibRequired) + +install(TARGETS testLibDepends EXPORT DependsExp DESTINATION lib ) +install(EXPORT DependsExp FILE testLibDependsConfig.cmake DESTINATION lib/cmake/testLibDepends) + + # Install and export from install tree. install( TARGETS diff --git a/Tests/ExportImport/Export/testLibDepends.c b/Tests/ExportImport/Export/testLibDepends.c new file mode 100644 index 000000000..2849b336d --- /dev/null +++ b/Tests/ExportImport/Export/testLibDepends.c @@ -0,0 +1,4 @@ + +extern int testLibRequired(void); + +int testLibDepends(void) { return testLibRequired(); } diff --git a/Tests/ExportImport/Export/testLibRequired.c b/Tests/ExportImport/Export/testLibRequired.c new file mode 100644 index 000000000..e126d44e7 --- /dev/null +++ b/Tests/ExportImport/Export/testLibRequired.c @@ -0,0 +1 @@ +int testLibRequired(void) { return 0; } diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 650af6adf..884179225 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -4,6 +4,10 @@ include(${Import_BINARY_DIR}/../Export/ExportBuildTree.cmake) # Import targets from the exported install tree. 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) + # Try referencing an executable imported from the install tree. add_custom_command( OUTPUT ${Import_BINARY_DIR}/exp_generated.c