diff options
author | Brad King <brad.king@kitware.com> | 2010-12-08 17:22:13 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2010-12-08 17:22:13 (GMT) |
commit | a765c491adc47c05ce0da933c9cb8aae84f5e530 (patch) | |
tree | 79915e212dada62e97185711e1dbdb7c9488e0db /Tests/ExportImport | |
parent | e01cce28694201342adc97825982ed66fc52af65 (diff) | |
download | CMake-a765c491adc47c05ce0da933c9cb8aae84f5e530.zip CMake-a765c491adc47c05ce0da933c9cb8aae84f5e530.tar.gz CMake-a765c491adc47c05ce0da933c9cb8aae84f5e530.tar.bz2 |
Honor custom command dependencies on imported targets (#10395)
Imported targets do not themselves build, but we can follow dependencies
through them to find real targets. This allows imported targets to
depend on custom targets that provide the underlying files at build
time.
Diffstat (limited to 'Tests/ExportImport')
-rw-r--r-- | Tests/ExportImport/Import/A/CMakeLists.txt | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 0828343..e65e362 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -75,24 +75,64 @@ foreach(c DEBUG RELWITHDEBINFO) set_property(TARGET imp_testExe1b PROPERTY COMPILE_DEFINITIONS_${c} EXE_DBG) endforeach(c) +#----------------------------------------------------------------------------- # Create a custom target to generate a header for the libraries below. -include_directories(${CMAKE_CURRENT_BINARY_DIR}) +# Drive the header generation through an indirect chain of imported +# target dependencies. + +# testLib2tmp1.h add_custom_command( - OUTPUT testLib2.h + OUTPUT testLib2tmp1.h VERBATIM COMMAND - ${CMAKE_COMMAND} -E echo "extern int testLib2(void);" > testLib2.h + ${CMAKE_COMMAND} -E echo "extern int testLib2(void);" > testLib2tmp1.h + ) + +# hdr_testLib2tmp1 needs testLib2tmp1.h +add_custom_target(hdr_testLib2tmp1 DEPENDS testLib2tmp1.h) + +# exp_testExe2 needs hdr_testLib2tmp1 +add_dependencies(exp_testExe2 hdr_testLib2tmp1) + +# testLib2tmp.h needs exp_testExe2 +add_custom_command( + OUTPUT testLib2tmp.h + VERBATIM COMMAND exp_testExe2 + COMMAND ${CMAKE_COMMAND} -E copy testLib2tmp1.h testLib2tmp.h ) + +# hdr_testLib2tmp needs testLib2tmp.h +add_custom_target(hdr_testLib2tmp DEPENDS testLib2tmp.h) + +add_library(dep_testLib2tmp UNKNOWN IMPORTED) +set_property(TARGET dep_testLib2tmp PROPERTY + IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/testLib2tmp.h) + +# dep_testLib2tmp needs hdr_testLib2tmp +add_dependencies(dep_testLib2tmp hdr_testLib2tmp) + +# testLib2.h needs dep_testLib2tmp +add_custom_command( + OUTPUT testLib2.h + VERBATIM COMMAND ${CMAKE_COMMAND} -E copy testLib2tmp.h testLib2.h + DEPENDS dep_testLib2tmp + ) + +# hdr_testLib2 needs testLib2.h add_custom_target(hdr_testLib2 DEPENDS testLib2.h) -# Drive the header generation through an indirect chain of imported -# target dependencies. add_library(dep_testLib2 UNKNOWN IMPORTED) + +# dep_testLib2 needs hdr_testLib2 add_dependencies(dep_testLib2 hdr_testLib2) + +# exp_testLib2 and bld_testLib2 both need dep_testLib2 add_dependencies(bld_testLib2 dep_testLib2) add_dependencies(exp_testLib2 dep_testLib2) +#----------------------------------------------------------------------------- # Create a library to be linked by another directory in this project # to test transitive linking to otherwise invisible imported targets. +include_directories(${CMAKE_CURRENT_BINARY_DIR}) add_library(imp_lib1 STATIC imp_lib1.c) target_link_libraries(imp_lib1 exp_testLib2) add_library(imp_lib1b STATIC imp_lib1.c) |