diff options
author | Abdelmaged Khalifa <abdelmaged.khalifa@gmail.com> | 2023-02-11 23:00:40 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-02-14 13:56:59 (GMT) |
commit | 082ccd75301cd02efd09bb9882bb9d2a8957193b (patch) | |
tree | 92611f898b4b3253c12687faa610f0bc8a0d0de8 /Source/cmLocalNinjaGenerator.cxx | |
parent | 48c69eeafe5e480b5baa0c6766d4d2e3c7f5a4ad (diff) | |
download | CMake-082ccd75301cd02efd09bb9882bb9d2a8957193b.zip CMake-082ccd75301cd02efd09bb9882bb9d2a8957193b.tar.gz CMake-082ccd75301cd02efd09bb9882bb9d2a8957193b.tar.bz2 |
add_custom_command: Add DEPENDS_EXPLICIT_ONLY option for Ninja
Add option `DEPENDS_EXPLICIT_ONLY` to `add_custom_command` to indicate
that implicit dependencies coming from users of the output are not
needed, and only consider dependencies explicitly specified in the
custom command.
Fixes: #17097
Diffstat (limited to 'Source/cmLocalNinjaGenerator.cxx')
-rw-r--r-- | Source/cmLocalNinjaGenerator.cxx | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 1e2ea2a..f8027c0 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -586,32 +586,34 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatement( cmNinjaDeps orderOnlyDeps; - // A custom command may appear on multiple targets. However, some build - // systems exist where the target dependencies on some of the targets are - // overspecified, leading to a dependency cycle. If we assume all target - // dependencies are a superset of the true target dependencies for this - // custom command, we can take the set intersection of all target - // dependencies to obtain a correct dependency list. - // - // FIXME: This won't work in certain obscure scenarios involving indirect - // dependencies. - auto j = targets.begin(); - assert(j != targets.end()); - this->GetGlobalNinjaGenerator()->AppendTargetDependsClosure( - *j, orderOnlyDeps, ccg.GetOutputConfig(), fileConfig, ccgs.size() > 1); - std::sort(orderOnlyDeps.begin(), orderOnlyDeps.end()); - ++j; - - for (; j != targets.end(); ++j) { - std::vector<std::string> jDeps; - std::vector<std::string> depsIntersection; + if (!cc->GetDependsExplicitOnly()) { + // A custom command may appear on multiple targets. However, some build + // systems exist where the target dependencies on some of the targets are + // overspecified, leading to a dependency cycle. If we assume all target + // dependencies are a superset of the true target dependencies for this + // custom command, we can take the set intersection of all target + // dependencies to obtain a correct dependency list. + // + // FIXME: This won't work in certain obscure scenarios involving indirect + // dependencies. + auto j = targets.begin(); + assert(j != targets.end()); this->GetGlobalNinjaGenerator()->AppendTargetDependsClosure( - *j, jDeps, ccg.GetOutputConfig(), fileConfig, ccgs.size() > 1); - std::sort(jDeps.begin(), jDeps.end()); - std::set_intersection(orderOnlyDeps.begin(), orderOnlyDeps.end(), - jDeps.begin(), jDeps.end(), - std::back_inserter(depsIntersection)); - orderOnlyDeps = depsIntersection; + *j, orderOnlyDeps, ccg.GetOutputConfig(), fileConfig, ccgs.size() > 1); + std::sort(orderOnlyDeps.begin(), orderOnlyDeps.end()); + ++j; + + for (; j != targets.end(); ++j) { + std::vector<std::string> jDeps; + std::vector<std::string> depsIntersection; + this->GetGlobalNinjaGenerator()->AppendTargetDependsClosure( + *j, jDeps, ccg.GetOutputConfig(), fileConfig, ccgs.size() > 1); + std::sort(jDeps.begin(), jDeps.end()); + std::set_intersection(orderOnlyDeps.begin(), orderOnlyDeps.end(), + jDeps.begin(), jDeps.end(), + std::back_inserter(depsIntersection)); + orderOnlyDeps = depsIntersection; + } } const std::vector<std::string>& outputs = ccg.GetOutputs(); |