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
This commit is contained in:
Alex Neundorf 2012-09-23 19:19:55 +02:00 committed by Brad King
parent 6f50a04cc1
commit 955b96629e
4 changed files with 21 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1,4 @@
extern int testLibRequired(void);
int testLibDepends(void) { return testLibRequired(); }

View File

@ -0,0 +1 @@
int testLibRequired(void) { return 0; }

View File

@ -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