diff options
author | Brad King <brad.king@kitware.com> | 2017-03-09 20:28:14 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-03-09 21:25:14 (GMT) |
commit | 25d261efa7c80ce7d9cbcb8b94d5d4a77cb12aaf (patch) | |
tree | d6b00210307b010f08388a337fdb5b879be25bd3 /Source/cmGeneratorTarget.cxx | |
parent | 1e0a9ac45d51e0076222026b9c44604b287a6eae (diff) | |
download | CMake-25d261efa7c80ce7d9cbcb8b94d5d4a77cb12aaf.zip CMake-25d261efa7c80ce7d9cbcb8b94d5d4a77cb12aaf.tar.gz CMake-25d261efa7c80ce7d9cbcb8b94d5d4a77cb12aaf.tar.bz2 |
Refactor module definition file selection
Create a `ModuleDefinitionInfo` structure for each configuration of a
target to hold corresponding information about the selected module
definition file (`.def` source).
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 39336b2..acaa383 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1944,16 +1944,40 @@ cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo( return &i->second; } -cmSourceFile const* cmGeneratorTarget::GetModuleDefinitionFile( - const std::string& config) const +cmGeneratorTarget::ModuleDefinitionInfo const* +cmGeneratorTarget::GetModuleDefinitionInfo(std::string const& config) const { - std::vector<cmSourceFile const*> data; - this->GetModuleDefinitionSources(data, config); - if (!data.empty()) { - return data.front(); + // A module definition file only makes sense on certain target types. + if (this->GetType() != cmStateEnums::SHARED_LIBRARY && + this->GetType() != cmStateEnums::MODULE_LIBRARY && + !this->IsExecutableWithExports()) { + return CM_NULLPTR; } - return CM_NULLPTR; + // Lookup/compute/cache the compile information for this configuration. + std::string config_upper; + if (!config.empty()) { + config_upper = cmSystemTools::UpperCase(config); + } + ModuleDefinitionInfoMapType::const_iterator i = + this->ModuleDefinitionInfoMap.find(config_upper); + if (i == this->ModuleDefinitionInfoMap.end()) { + ModuleDefinitionInfo info; + this->ComputeModuleDefinitionInfo(config, info); + ModuleDefinitionInfoMapType::value_type entry(config_upper, info); + i = this->ModuleDefinitionInfoMap.insert(entry).first; + } + return &i->second; +} + +void cmGeneratorTarget::ComputeModuleDefinitionInfo( + std::string const& config, ModuleDefinitionInfo& info) const +{ + std::vector<cmSourceFile const*> sources; + this->GetModuleDefinitionSources(sources, config); + if (!sources.empty()) { + info.DefFile = sources.front()->GetFullPath(); + } } bool cmGeneratorTarget::IsDLLPlatform() const |