diff options
author | Peter Kuemmel <syntheticpp@gmx.net> | 2012-03-06 22:41:40 (GMT) |
---|---|---|
committer | David Cole <david.cole@kitware.com> | 2012-03-07 21:24:34 (GMT) |
commit | dbe3dce54670d774fd43e061be673b11e1dd18de (patch) | |
tree | 0d18d9aef32bdd66ff103f04f1f401d6d5373682 | |
parent | f1bb08f55b1ee0e8ae72d66289ad89ad27d75701 (diff) | |
download | CMake-dbe3dce54670d774fd43e061be673b11e1dd18de.zip CMake-dbe3dce54670d774fd43e061be673b11e1dd18de.tar.gz CMake-dbe3dce54670d774fd43e061be673b11e1dd18de.tar.bz2 |
Ninja: add .def file support
-rw-r--r-- | Source/cmGlobalNinjaGenerator.h | 2 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 1 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 36 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.h | 6 |
5 files changed, 46 insertions, 1 deletions
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 3f8644e..e77252f 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -325,6 +325,8 @@ private: typedef std::map<std::string, cmTarget*> TargetAliasMap; TargetAliasMap TargetAliases; + + static cmLocalGenerator* LocalGenerator; }; #endif // ! cmGlobalNinjaGenerator_h diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index aa3286c..3920b89 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1503,7 +1503,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, linkFlags += this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG"); linkFlags += this->Convert(sf->GetFullPath().c_str(), - START_OUTPUT, SHELL); + FULL, SHELL); linkFlags += " "; } } diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index f4069c7..9e05b4c 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -285,6 +285,7 @@ cmNinjaNormalTargetGenerator default: assert(0 && "Unexpected target type"); } + const char *linkCmd = this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); cmSystemTools::ExpandListArgument(linkCmd, linkCmds); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index d0b4156..8fa367f 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -229,6 +229,13 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const const std::vector<std::string> &deps = cli->GetDepends(); cmNinjaDeps result(deps.size()); std::transform(deps.begin(), deps.end(), result.begin(), MapToNinjaPath()); + + // Add a dependency on the link definitions file, if any. + if(!this->ModuleDefinitionFile.empty()) + { + result.push_back(this->ModuleDefinitionFile); + } + return result; } @@ -328,6 +335,7 @@ cmNinjaTargetGenerator } vars.Flags = flags.c_str(); + // Rule for compiling object file. std::string compileCmdVar = "CMAKE_"; compileCmdVar += language; @@ -395,6 +403,8 @@ cmNinjaTargetGenerator if (!language) { if (source->GetPropertyAsBool("EXTERNAL_OBJECT")) this->Objects.push_back(this->GetSourceFilePath(source)); + if(cmSystemTools::UpperCase(source->GetExtension()) == "DEF") + this->ModuleDefinitionFile = GetSourceFilePath(source); return; } @@ -465,3 +475,29 @@ cmNinjaTargetGenerator orderOnlyDeps, vars); } + +//---------------------------------------------------------------------------- +void +cmNinjaTargetGenerator +::AddModuleDefinitionFlag(std::string& flags) +{ + if(this->ModuleDefinitionFile.empty()) + { + return; + } + + // TODO: Create a per-language flag variable. + const char* defFileFlag = + this->Makefile->GetDefinition("CMAKE_LINK_DEF_FILE_FLAG"); + if(!defFileFlag) + { + return; + } + + // Append the flag and value. Use ConvertToLinkReference to help + // vs6's "cl -link" pass it to the linker. + std::string flag = defFileFlag; + flag += (this->LocalGenerator->ConvertToLinkReference( + this->ModuleDefinitionFile.c_str())); + this->LocalGenerator->AppendFlags(flags, flag.c_str()); +} diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index f9270a2..3e70a2c 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -107,12 +107,18 @@ protected: cmNinjaDeps GetObjects() const { return this->Objects; } + // Helper to add flag for windows .def file. + void AddModuleDefinitionFlag(std::string& flags); + private: cmTarget* Target; cmMakefile* Makefile; cmLocalNinjaGenerator* LocalGenerator; /// List of object files for this target. cmNinjaDeps Objects; + + // The windows module definition source file (.def), if any. + std::string ModuleDefinitionFile; }; #endif // ! cmNinjaTargetGenerator_h |