diff options
author | Brad King <brad.king@kitware.com> | 2016-08-10 15:15:55 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2016-08-10 15:15:55 (GMT) |
commit | e01c576338ae448d9cbf18cc065567fde5c89f3b (patch) | |
tree | 746365b513449a7f40add5a3c0da42fc8eb3f9ea /Source | |
parent | 627ffb4bd768609019014828d7480c22997cda0c (diff) | |
parent | 0278989405eea53ca7e5f1bfa6af9aea7a0b49c5 (diff) | |
download | CMake-e01c576338ae448d9cbf18cc065567fde5c89f3b.zip CMake-e01c576338ae448d9cbf18cc065567fde5c89f3b.tar.gz CMake-e01c576338ae448d9cbf18cc065567fde5c89f3b.tar.bz2 |
Merge topic 'ninja-directory-targets'
02789894 Ninja: Add `$subdir/{test,install,package}` targets
a88c99f1 Ninja: Simplify computation of GLOBAL_TARGET outputs
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 18 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 13 | ||||
-rw-r--r-- | Source/cmNinjaUtilityTargetGenerator.cxx | 17 |
3 files changed, 22 insertions, 26 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 44418f2..3b8aaa6 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -867,6 +867,7 @@ void cmGlobalNinjaGenerator::AppendTargetOutputs( break; } case cmState::OBJECT_LIBRARY: + case cmState::GLOBAL_TARGET: case cmState::UTILITY: { std::string path = target->GetLocalGenerator()->GetCurrentBinaryDirectory() + @@ -875,12 +876,6 @@ void cmGlobalNinjaGenerator::AppendTargetOutputs( break; } - case cmState::GLOBAL_TARGET: - // Always use the target in HOME instead of an unused duplicate in a - // subdirectory. - outputs.push_back(this->NinjaOutputPath(target->GetName())); - break; - default: return; } @@ -890,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); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 1466f8a..9030e05 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -38,19 +38,8 @@ cmNinjaTargetGenerator* cmNinjaTargetGenerator::New(cmGeneratorTarget* target) return new cmNinjaNormalTargetGenerator(target); case cmState::UTILITY: + case cmState::GLOBAL_TARGET: return new cmNinjaUtilityTargetGenerator(target); - ; - - case cmState::GLOBAL_TARGET: { - // We only want to process global targets that live in the home - // (i.e. top-level) directory. CMake creates copies of these targets - // in every directory, which we don't need. - if (strcmp(target->GetLocalGenerator()->GetCurrentSourceDirectory(), - target->GetLocalGenerator()->GetSourceDirectory()) == 0) { - return new cmNinjaUtilityTargetGenerator(target); - } - // else fallthrough - } default: return CM_NULLPTR; 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()); + } } |