diff options
author | Brad King <brad.king@kitware.com> | 2012-03-13 14:05:07 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2012-03-16 14:18:36 (GMT) |
commit | 61124de4c06b1195e79ee71326b902baf23c4c32 (patch) | |
tree | 827dc5df380c74bb7ea8186fcc63d446b5fd31c5 /Source/cmNinjaNormalTargetGenerator.cxx | |
parent | f5b06cda0f187929ac68ed64595c22d4e6ec773c (diff) | |
download | CMake-61124de4c06b1195e79ee71326b902baf23c4c32.zip CMake-61124de4c06b1195e79ee71326b902baf23c4c32.tar.gz CMake-61124de4c06b1195e79ee71326b902baf23c4c32.tar.bz2 |
Build object library targets in Ninja
Treat OBJECT libraries as STATIC libraries but leave out the archive
step. The object files will be left behind for reference by other
targets later.
Diffstat (limited to 'Source/cmNinjaNormalTargetGenerator.cxx')
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 9242181..6859445 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -43,10 +43,13 @@ cmNinjaNormalTargetGenerator(cmTarget* target) this->TargetNamePDB, GetLocalGenerator()->GetConfigName()); - // on Windows the output dir is already needed at compile time - // ensure the directory exists (OutDir test) - std::string outpath = target->GetDirectory(this->GetConfigName()); - cmSystemTools::MakeDirectory(outpath.c_str()); + if(target->GetType() != cmTarget::OBJECT_LIBRARY) + { + // on Windows the output dir is already needed at compile time + // ensure the directory exists (OutDir test) + std::string outpath = target->GetDirectory(this->GetConfigName()); + cmSystemTools::MakeDirectory(outpath.c_str()); + } } cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator() @@ -67,8 +70,15 @@ void cmNinjaNormalTargetGenerator::Generate() // Write the build statements this->WriteObjectBuildStatements(); - this->WriteLinkRule(); - this->WriteLinkStatement(); + if(this->GetTarget()->GetType() == cmTarget::OBJECT_LIBRARY) + { + this->WriteObjectLibStatement(); + } + else + { + this->WriteLinkRule(); + this->WriteLinkStatement(); + } this->GetBuildFileStream() << "\n"; this->GetRulesFileStream() << "\n"; @@ -467,3 +477,21 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(), this->GetTarget()); } + +//---------------------------------------------------------------------------- +void cmNinjaNormalTargetGenerator::WriteObjectLibStatement() +{ + // Write a phony output that depends on all object files. + cmNinjaDeps outputs; + this->GetLocalGenerator()->AppendTargetOutputs(this->GetTarget(), outputs); + cmNinjaDeps depends = this->GetObjects(); + cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(), + "Object library " + + this->GetTargetName(), + outputs, + depends); + + // Add aliases for the target name. + this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(), + this->GetTarget()); +} |