Previously all explicit dependencies inside build folder were considered as possible build command side-effects and phony rules were produced for them in case they don't exist yet starting build. This however incorrect since regular compile inputs need to exist otherwise cmake will fail. Moreover the exception for sources having GENERATED property that can be missing is already handled by WriteAssumedSourceDependencies.
This fixes unwanted phony rules for all regular source files when doing in-source build, causing Ninja not complain when such files gets missing, i.e. during development. Also this reduces number of rules in ninja.build. Now only custom command dependencies are considered as possible side-effects. --- Source/cmGlobalNinjaGenerator.cxx | 22 ++++++++++++---------- Source/cmGlobalNinjaGenerator.h | 9 +++++---- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 0facfeb..eb01654 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -151,11 +151,6 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, ++i) { arguments += " " + EncodeIdent(EncodePath(*i), os); - - //we need to track every dependency that comes in, since we are trying - //to find dependencies that are side effects of build commands - // - this->CombinedBuildExplicitDependencies.insert( EncodePath(*i) ); } // Write implicit dependencies. @@ -280,6 +275,13 @@ cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command, cmNinjaDeps(), orderOnly, vars); + + //we need to track every dependency that comes in, since we are trying + //to find dependencies that are side effects of build commands + for(cmNinjaDeps::const_iterator i = deps.begin(); i != deps.end(); ++i) + { + this->CombinedCustomCommandExplicitDependencies.insert( EncodePath(*i) ); + } } void @@ -1015,17 +1017,17 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) //to keep this data around this->CombinedBuildOutputs.clear(); - //now we difference with CombinedBuildExplicitDependencies to find + //now we difference with CombinedCustomCommandExplicitDependencies to find //the list of items we know nothing about. - //We have encoded all the paths in CombinedBuildExplicitDependencies + //We have encoded all the paths in CombinedCustomCommandExplicitDependencies //and knownDependencies so no matter if unix or windows paths they //should all match now. std::vector<std::string> unkownExplicitDepends; - this->CombinedBuildExplicitDependencies.erase("all"); + this->CombinedCustomCommandExplicitDependencies.erase("all"); - std::set_difference(this->CombinedBuildExplicitDependencies.begin(), - this->CombinedBuildExplicitDependencies.end(), + std::set_difference(this->CombinedCustomCommandExplicitDependencies.begin(), + this->CombinedCustomCommandExplicitDependencies.end(), knownDependencies.begin(), knownDependencies.end(), std::back_inserter(unkownExplicitDepends)); diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index f2643af..ff110d7 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -363,10 +363,11 @@ private: /// The set of custom command outputs we have seen. std::set<std::string> CustomCommandOutputs; - //The combined explicit dependencies of all build commands that the global - //generator has issued. When combined with CombinedBuildOutputs it allows - //us to detect the set of explicit dependencies that have - std::set<std::string> CombinedBuildExplicitDependencies; + /// The combined explicit dependencies of custom build commands + std::set<std::string> CombinedCustomCommandExplicitDependencies; + + /// When combined with CombinedCustomCommandExplicitDependencies it allows + /// us to detect the set of explicit dependencies that have std::set<std::string> CombinedBuildOutputs; /// The mapping from source file to assumed dependencies. -- 1.9.3 (Apple Git-50) -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers