summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2010-12-14 19:38:04 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2010-12-14 19:38:04 (GMT)
commitadf62a98f3460899337b00eb9553b86baf691806 (patch)
treef5aaf7e2ef8695900f6da31a4f1b96655270f220
parent75844666ac03a95c6546cafb54bce8827e1b664a (diff)
parenta765c491adc47c05ce0da933c9cb8aae84f5e530 (diff)
downloadCMake-adf62a98f3460899337b00eb9553b86baf691806.zip
CMake-adf62a98f3460899337b00eb9553b86baf691806.tar.gz
CMake-adf62a98f3460899337b00eb9553b86baf691806.tar.bz2
Merge topic 'imported-target-dependencies'
a765c49 Honor custom command dependencies on imported targets (#10395)
-rw-r--r--Source/cmTarget.cxx8
-rw-r--r--Tests/ExportImport/Import/A/CMakeLists.txt50
2 files changed, 49 insertions, 9 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index ca61b1f..c82c11e 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -1357,8 +1357,8 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep)
util = cmSystemTools::GetFilenameWithoutLastExtension(util);
}
- // Check for a non-imported target with this name.
- if(cmTarget* t = this->GlobalGenerator->FindTarget(0, util.c_str()))
+ // Check for a target with this name.
+ if(cmTarget* t = this->Makefile->FindTargetToUse(util.c_str()))
{
// If we find the target and the dep was given as a full path,
// then make sure it was not a full path to something else, and
@@ -1406,8 +1406,8 @@ cmTargetTraceDependencies
cit != cc.GetCommandLines().end(); ++cit)
{
std::string const& command = *cit->begin();
- // Look for a non-imported target with this name.
- if(cmTarget* t = this->GlobalGenerator->FindTarget(0, command.c_str()))
+ // Check for a target with this name.
+ if(cmTarget* t = this->Makefile->FindTargetToUse(command.c_str()))
{
if(t->GetType() == cmTarget::EXECUTABLE)
{
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)