summaryrefslogtreecommitdiff
path: root/Source/cmGlobalNinjaGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-08-05 15:55:32 -0400
committerBrad King <brad.king@kitware.com>2016-08-09 15:15:24 -0400
commit0278989405eea53ca7e5f1bfa6af9aea7a0b49c5 (patch)
treeb51f07947692aa3d95eef9299ee588061be83afc /Source/cmGlobalNinjaGenerator.cxx
parenta88c99f1bc301276a1780fec683d5061ca13f66f (diff)
downloadcmake-0278989405eea53ca7e5f1bfa6af9aea7a0b49c5.tar.gz
Ninja: Add `$subdir/{test,install,package}` targets
With the Makefile generator one can use `cd $subdir; make install` to build and install targets associated with a given subdirectory. This is not possible to do with the Ninja generator since there is only one `build.ninja` file at the top of the build tree. However, we can approximate it by allowing one to run `ninja $subdir/install` at the top of the tree to build the targets in the corresponding subdirectory and install them. This also makes sense for `test`, `package`, and other GLOBAL_TARGET targets. It was already done for `all` by commit v3.6.0-rc1~240^2~2 (Ninja: Add `$subdir/all` targets, 2016-03-11).
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx11
1 files changed, 8 insertions, 3 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index afd43b8dc1..3b8aaa6476 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -885,10 +885,15 @@ void cmGlobalNinjaGenerator::AppendTargetDepends(
cmGeneratorTarget const* target, cmNinjaDeps& outputs)
{
if (target->GetType() == cmState::GLOBAL_TARGET) {
- // Global targets only depend on other utilities, which may not appear in
- // the TargetDepends set (e.g. "all").
+ // These depend only on other CMake-provided targets, e.g. "all".
std::set<std::string> const& utils = target->GetUtilities();
- std::copy(utils.begin(), utils.end(), std::back_inserter(outputs));
+ for (std::set<std::string>::const_iterator i = utils.begin();
+ i != utils.end(); ++i) {
+ std::string d =
+ target->GetLocalGenerator()->GetCurrentBinaryDirectory() +
+ std::string("/") + *i;
+ outputs.push_back(this->ConvertToNinjaPath(d));
+ }
} else {
cmNinjaDeps outs;
cmTargetDependSet const& targetDeps = this->GetTargetDirectDepends(target);