diff options
author | Brad King <brad.king@kitware.com> | 2016-08-05 19:55:32 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-08-09 19:15:24 (GMT) |
commit | 0278989405eea53ca7e5f1bfa6af9aea7a0b49c5 (patch) | |
tree | b51f07947692aa3d95eef9299ee588061be83afc /Source/cmNinjaUtilityTargetGenerator.cxx | |
parent | a88c99f1bc301276a1780fec683d5061ca13f66f (diff) | |
download | CMake-0278989405eea53ca7e5f1bfa6af9aea7a0b49c5.zip CMake-0278989405eea53ca7e5f1bfa6af9aea7a0b49c5.tar.gz CMake-0278989405eea53ca7e5f1bfa6af9aea7a0b49c5.tar.bz2 |
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/cmNinjaUtilityTargetGenerator.cxx')
-rw-r--r-- | Source/cmNinjaUtilityTargetGenerator.cxx | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index c549646..96a17ff 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -31,10 +31,12 @@ cmNinjaUtilityTargetGenerator::~cmNinjaUtilityTargetGenerator() void cmNinjaUtilityTargetGenerator::Generate() { - std::string utilCommandName = cmake::GetCMakeFilesDirectoryPostSlash(); + std::string utilCommandName = + this->GetLocalGenerator()->GetCurrentBinaryDirectory(); + utilCommandName += cmake::GetCMakeFilesDirectory(); + utilCommandName += "/"; utilCommandName += this->GetTargetName() + ".util"; - utilCommandName = - this->GetGlobalGenerator()->NinjaOutputPath(utilCommandName); + utilCommandName = this->ConvertToNinjaPath(utilCommandName); std::vector<std::string> commands; cmNinjaDeps deps, outputs, util_outputs(1, utilCommandName); @@ -144,6 +146,11 @@ void cmNinjaUtilityTargetGenerator::Generate() cmNinjaDeps(1, utilCommandName)); } - this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(), - this->GetGeneratorTarget()); + // Add an alias for the logical target name regardless of what directory + // contains it. Skip this for GLOBAL_TARGET because they are meant to + // be per-directory and have one at the top-level anyway. + if (this->GetGeneratorTarget()->GetType() != cmState::GLOBAL_TARGET) { + this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(), + this->GetGeneratorTarget()); + } } |