From ced1d5eccd4ae08a6431a5c163be3dd52ca9d59a Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 8 Dec 2010 17:05:23 -0500 Subject: [PATCH] Skip file-level dependencies on custom targets (#11332) A custom command may name a target created by add_custom_target in its DEPENDS field. Treat this case as a target-level dependency only since a custom target provides no standard file on which to add a file-level dependency. --- Source/cmLocalGenerator.cxx | 7 +++---- Source/cmLocalGenerator.h | 1 + Tests/CustomCommand/CMakeLists.txt | 5 +---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 6b37eafe4..b7d694c1d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1878,10 +1878,9 @@ bool cmLocalGenerator::GetRealDependency(const char* inName, break; case cmTarget::UTILITY: case cmTarget::GLOBAL_TARGET: - // Depending on a utility target may not work but just trust - // the user to have given a valid name. - dep = inName; - return true; + // A utility target has no file on which to depend. This was listed + // only to get the target-level dependency. + return false; case cmTarget::INSTALL_FILES: case cmTarget::INSTALL_PROGRAMS: case cmTarget::INSTALL_DIRECTORY: diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 486c385f7..870ce361d 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -158,6 +158,7 @@ public: /** Translate a dependency as given in CMake code to the name to appear in a generated build file. If the given name is that of + a utility target, returns false. If the given name is that of a CMake target it will be transformed to the real output location of that target for the given configuration. If the given name is the full path to a file it will be returned. diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index 76208d479..746c9a71b 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -130,6 +130,7 @@ ADD_CUSTOM_COMMAND( ################################################################ ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/foo.pre DEPENDS ${PROJECT_SOURCE_DIR}/foo.in + TDocument # Ensure doc1.h generates before this target COMMAND ${CMAKE_COMMAND} ARGS -E copy ${PROJECT_SOURCE_DIR}/foo.in ${PROJECT_BINARY_DIR}/foo.pre @@ -181,10 +182,6 @@ ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/generated.c TARGET_LINK_LIBRARIES(CustomCommand GeneratedHeader) -# must add a dependency on TDocument otherwise it might never build and -# the CustomCommand executable really needs doc1.h -ADD_DEPENDENCIES(CustomCommand TDocument) - ############################################################################## # Test for using just the target name as executable in the COMMAND # section. Has to be recognized and replaced by CMake with the output