diff options
author | Brad King <brad.king@kitware.com> | 2020-05-25 14:35:08 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-05-25 14:35:13 (GMT) |
commit | f7960e548808bc7412a1071c03ec7cb0ddd76c00 (patch) | |
tree | ef5a2246e8869e825465091618a9e0adb8668759 /Source | |
parent | 7b56d0a377fc8045b5714b4ccbfa3cacf1cf5e50 (diff) | |
parent | bcb44ac2ee0609b701fef84bcc333fda9b1c02b9 (diff) | |
download | CMake-f7960e548808bc7412a1071c03ec7cb0ddd76c00.zip CMake-f7960e548808bc7412a1071c03ec7cb0ddd76c00.tar.gz CMake-f7960e548808bc7412a1071c03ec7cb0ddd76c00.tar.bz2 |
Merge topic 'cuda-runtime-cleanup'
bcb44ac2ee CUDA: Simplify Clang implicit host linker settings
23519dd24f CUDA: Fix implicit runtime library filtering on Windows
16bed00712 CUDA: Refactor implicit library filtering
5c7ca6f8a8 CUDA: Move VS CudaRuntime selection to be with rest of CUDA options
4468acb979 CUDA: Factor runtime library lookup into helper method
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Robert Maynard <robert.maynard@kitware.com>
Merge-request: !4776
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmComputeLinkInformation.cxx | 39 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 19 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 3 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 15 | ||||
-rw-r--r-- | Source/cmVisualStudioGeneratorOptions.cxx | 28 | ||||
-rw-r--r-- | Source/cmVisualStudioGeneratorOptions.h | 1 |
6 files changed, 45 insertions, 60 deletions
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index ea7ede4..8723d08 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -12,7 +12,6 @@ #include <cmext/algorithm> #include "cmComputeLinkDepends.h" -#include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" #include "cmListFileCache.h" @@ -587,32 +586,18 @@ void cmComputeLinkInformation::AddImplicitLinkInfo() } void cmComputeLinkInformation::AddRuntimeLinkLibrary(std::string const& lang) -{ // Add the lang runtime library flags. This is activated by the presence - // of a default selection whether or not it is overridden by a property. - std::string defaultVar = - cmStrCat("CMAKE_", lang, "_RUNTIME_LIBRARY_DEFAULT"); - cmProp langRuntimeLibraryDefault = this->Makefile->GetDef(defaultVar); - if (langRuntimeLibraryDefault && !langRuntimeLibraryDefault->empty()) { - cmProp runtimeLibraryValue = - this->Target->GetProperty(cmStrCat(lang, "_RUNTIME_LIBRARY")); - if (!runtimeLibraryValue) { - runtimeLibraryValue = langRuntimeLibraryDefault; - } - - std::string runtimeLibrary = - cmSystemTools::UpperCase(cmGeneratorExpression::Evaluate( - *runtimeLibraryValue, this->Target->GetLocalGenerator(), this->Config, - this->Target)); - if (!runtimeLibrary.empty()) { - if (const char* runtimeLinkOptions = this->Makefile->GetDefinition( - "CMAKE_" + lang + "_RUNTIME_LIBRARY_LINK_OPTIONS_" + - runtimeLibrary)) { - std::vector<std::string> libsVec = cmExpandedList(runtimeLinkOptions); - for (std::string const& i : libsVec) { - if (!cm::contains(this->ImplicitLinkLibs, i)) { - this->AddItem(i, nullptr); - } - } +{ + std::string const& runtimeLibrary = + this->Target->GetRuntimeLinkLibrary(lang, this->Config); + if (runtimeLibrary.empty()) { + return; + } + if (const char* runtimeLinkOptions = this->Makefile->GetDefinition( + "CMAKE_" + lang + "_RUNTIME_LIBRARY_LINK_OPTIONS_" + runtimeLibrary)) { + std::vector<std::string> libsVec = cmExpandedList(runtimeLinkOptions); + for (std::string const& i : libsVec) { + if (!cm::contains(this->ImplicitLinkLibs, i)) { + this->AddItem(i, nullptr); } } } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 917985a..f2a51ab 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -5710,6 +5710,25 @@ void cmGeneratorTarget::GetTargetVersion(const std::string& property, } } +std::string cmGeneratorTarget::GetRuntimeLinkLibrary( + std::string const& lang, std::string const& config) const +{ + // This is activated by the presence of a default selection whether or + // not it is overridden by a property. + cmProp runtimeLibraryDefault = this->Makefile->GetDef( + cmStrCat("CMAKE_", lang, "_RUNTIME_LIBRARY_DEFAULT")); + if (!runtimeLibraryDefault || runtimeLibraryDefault->empty()) { + return std::string(); + } + cmProp runtimeLibraryValue = + this->Target->GetProperty(cmStrCat(lang, "_RUNTIME_LIBRARY")); + if (!runtimeLibraryValue) { + runtimeLibraryValue = runtimeLibraryDefault; + } + return cmSystemTools::UpperCase(cmGeneratorExpression::Evaluate( + *runtimeLibraryValue, this->LocalGenerator, config, this)); +} + std::string cmGeneratorTarget::GetFortranModuleDirectory( std::string const& working_dir) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index c8732bc..788fa23 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -783,6 +783,9 @@ public: const std::string& fallback_property, int& major, int& minor, int& patch) const; + std::string GetRuntimeLinkLibrary(std::string const& lang, + std::string const& config) const; + std::string GetFortranModuleDirectory(std::string const& working_dir) const; const std::string& GetSourcesProperty() const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 97f7093..de88182 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -3130,6 +3130,17 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions( cudaOptions.AddIncludes(this->GetIncludes(configName, "CUDA")); cudaOptions.AddFlag("UseHostInclude", "false"); + // Add runtime library selection flag. + std::string const& cudaRuntime = + this->GeneratorTarget->GetRuntimeLinkLibrary("CUDA", configName); + if (cudaRuntime == "STATIC") { + cudaOptions.AddFlag("CudaRuntime", "Static"); + } else if (cudaRuntime == "SHARED") { + cudaOptions.AddFlag("CudaRuntime", "Shared"); + } else if (cudaRuntime == "NONE") { + cudaOptions.AddFlag("CudaRuntime", "None"); + } + this->CudaOptions[configName] = std::move(pOptions); return true; } @@ -3644,10 +3655,6 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( std::vector<std::string> libVec; std::vector<std::string> vsTargetVec; this->AddLibraries(cli, libVec, vsTargetVec, config); - if (cm::contains(linkClosure->Languages, "CUDA") && - this->CudaOptions[config] != nullptr) { - this->CudaOptions[config]->FixCudaRuntime(this->GeneratorTarget); - } std::string standardLibsVar = cmStrCat("CMAKE_", linkLanguage, "_STANDARD_LIBRARIES"); std::string const& libs = this->Makefile->GetSafeDefinition(standardLibsVar); diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index 7775f62..937b4ce 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -151,34 +151,6 @@ bool cmVisualStudioGeneratorOptions::UsingSBCS() const return false; } -void cmVisualStudioGeneratorOptions::FixCudaRuntime(cmGeneratorTarget* target) -{ - std::map<std::string, FlagValue>::const_iterator i = - this->FlagMap.find("CudaRuntime"); - if (i == this->FlagMap.end()) { - // User didn't provide am override so get the property value - cmProp runtimeLibraryValue = target->GetProperty("CUDA_RUNTIME_LIBRARY"); - if (runtimeLibraryValue) { - std::string cudaRuntime = - cmSystemTools::UpperCase(cmGeneratorExpression::Evaluate( - *runtimeLibraryValue, this->LocalGenerator, this->Configuration, - target)); - if (cudaRuntime == "STATIC") { - this->AddFlag("CudaRuntime", "Static"); - } - if (cudaRuntime == "SHARED") { - this->AddFlag("CudaRuntime", "Shared"); - } - if (cudaRuntime == "NONE") { - this->AddFlag("CudaRuntime", "None"); - } - } else { - // nvcc default is static - this->AddFlag("CudaRuntime", "Static"); - } - } -} - void cmVisualStudioGeneratorOptions::FixCudaCodeGeneration() { // Extract temporary values stored by our flag table. diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h index b335694..f9b50a7 100644 --- a/Source/cmVisualStudioGeneratorOptions.h +++ b/Source/cmVisualStudioGeneratorOptions.h @@ -63,7 +63,6 @@ public: bool UsingSBCS() const; void FixCudaCodeGeneration(); - void FixCudaRuntime(cmGeneratorTarget* target); void FixManifestUACFlags(); |