From 16fec7e2fc454a9fe64ac7ffa03a6d8adcc1320d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20St=C3=BCrmer?= Date: Tue, 20 Mar 2018 12:19:13 +0100 Subject: cmVisualStudio10TargetGenerator: make some methods config aware --- Source/cmVisualStudio10TargetGenerator.cxx | 26 +++++++++++++++++--------- Source/cmVisualStudio10TargetGenerator.h | 8 +++++--- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 4dabb4c..ef03ca5 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -711,21 +711,29 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences() ConvertToWindowsSlash(path); hintReferences.push_back(HintReference(name, path)); } else { - this->WriteDotNetReference(ri, ""); + this->WriteDotNetReference(ri, "", ""); } } for (const auto& i : hintReferences) { - this->WriteDotNetReference(i.first, i.second); + this->WriteDotNetReference(i.first, i.second, ""); } this->WriteString("\n", 1); } } void cmVisualStudio10TargetGenerator::WriteDotNetReference( - std::string const& ref, std::string const& hint) + std::string const& ref, std::string const& hint, std::string const& config) { - this->WriteString("BuildFileStream) << cmVS10EscapeAttr(ref) << "\">\n"; + std::string attr = " Include=\"" + cmVS10EscapeAttr(ref) + "\""; + // If 'config' is not empty, the reference is only added for the given + // configuration. This is used when referencing imported managed assemblies. + // See also cmVisualStudio10TargetGenerator::AddLibraries(). + if (!config.empty()) { + this->WritePlatformConfigTag("Reference", config, 2, attr.c_str()); + } else { + this->WriteString("BuildFileStream) << attr << ">\n"; + } this->WriteElem("CopyLocalSatelliteAssemblies", "true", 3); this->WriteElem("ReferenceOutputAssembly", "true", 3); if (!hint.empty()) { @@ -3262,7 +3270,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( std::vector libVec; std::vector vsTargetVec; - this->AddLibraries(cli, libVec, vsTargetVec); + this->AddLibraries(cli, libVec, vsTargetVec, config); if (std::find(linkClosure->Languages.begin(), linkClosure->Languages.end(), "CUDA") != linkClosure->Languages.end()) { switch (this->CudaOptions[config]->GetCudaRuntime()) { @@ -3478,8 +3486,8 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions( } void cmVisualStudio10TargetGenerator::AddLibraries( - cmComputeLinkInformation& cli, std::vector& libVec, - std::vector& vsTargetVec) + const cmComputeLinkInformation& cli, std::vector& libVec, + std::vector& vsTargetVec, const std::string& config) { typedef cmComputeLinkInformation::ItemVector ItemVector; ItemVector const& libs = cli.GetItems(); @@ -3487,7 +3495,7 @@ void cmVisualStudio10TargetGenerator::AddLibraries( this->LocalGenerator->GetCurrentBinaryDirectory(); for (cmComputeLinkInformation::Item const& l : libs) { if (l.Target) { - auto managedType = l.Target->GetManagedType(""); + auto managedType = l.Target->GetManagedType(config); // Do not allow C# targets to be added to the LIB listing. LIB files are // used for linking C++ dependencies. C# libraries do not have lib files. // Instead, they compile down to C# reference libraries (DLL files). The diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 3c53d1b..b6107d1 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -72,7 +72,8 @@ private: std::vector const& exclude_configs); void WriteAllSources(); void WriteDotNetReferences(); - void WriteDotNetReference(std::string const& ref, std::string const& hint); + void WriteDotNetReference(std::string const& ref, std::string const& hint, + std::string const& config); void WriteDotNetReferenceCustomTags(std::string const& ref); void WriteEmbeddedResourceGroup(); void WriteWinRTReferences(); @@ -147,9 +148,10 @@ private: void WriteProjectReferences(); void WriteApplicationTypeSettings(); void OutputSourceSpecificFlags(Elem&, cmSourceFile const* source); - void AddLibraries(cmComputeLinkInformation& cli, + void AddLibraries(const cmComputeLinkInformation& cli, std::vector& libVec, - std::vector& vsTargetVec); + std::vector& vsTargetVec, + const std::string& config); void AddTargetsFileAndConfigPair(std::string const& targetsFile, std::string const& config); void WriteLibOptions(std::string const& config); -- cgit v0.12