summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2010-11-19 18:36:11 (GMT)
committerBrad King <brad.king@kitware.com>2010-11-19 22:19:21 (GMT)
commite01cce28694201342adc97825982ed66fc52af65 (patch)
treeef4573c4112650f78df2ebb66665185118a8bcd6 /Tests
parentbc7395c096be40f8a0fecbab4aa7539c05898ef2 (diff)
downloadCMake-e01cce28694201342adc97825982ed66fc52af65.zip
CMake-e01cce28694201342adc97825982ed66fc52af65.tar.gz
CMake-e01cce28694201342adc97825982ed66fc52af65.tar.bz2
Allow add_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')
-rw-r--r--Tests/ExportImport/Import/A/CMakeLists.txt16
-rw-r--r--Tests/ExportImport/Import/A/imp_lib1.c2
2 files changed, 17 insertions, 1 deletions
diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt
index 34b8717..0828343 100644
--- a/Tests/ExportImport/Import/A/CMakeLists.txt
+++ b/Tests/ExportImport/Import/A/CMakeLists.txt
@@ -75,6 +75,22 @@ 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})
+add_custom_command(
+ OUTPUT testLib2.h
+ VERBATIM COMMAND
+ ${CMAKE_COMMAND} -E echo "extern int testLib2(void);" > 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)
+add_dependencies(dep_testLib2 hdr_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.
add_library(imp_lib1 STATIC imp_lib1.c)
diff --git a/Tests/ExportImport/Import/A/imp_lib1.c b/Tests/ExportImport/Import/A/imp_lib1.c
index d8c66e6..5b3215e 100644
--- a/Tests/ExportImport/Import/A/imp_lib1.c
+++ b/Tests/ExportImport/Import/A/imp_lib1.c
@@ -1,4 +1,4 @@
-extern int testLib2(void);
+#include "testLib2.h"
int imp_lib1(void)
{