summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-05-21 14:05:09 (GMT)
committerBrad King <brad.king@kitware.com>2020-05-22 12:15:32 (GMT)
commit4468acb979d04fc422a1c78a89c24a26b35f3629 (patch)
tree5bd15416fde53ba8a87dd2f0debe189944737957 /Source
parentfa6db3738a61d341132aa091becd39ddf75a2bec (diff)
downloadCMake-4468acb979d04fc422a1c78a89c24a26b35f3629.zip
CMake-4468acb979d04fc422a1c78a89c24a26b35f3629.tar.gz
CMake-4468acb979d04fc422a1c78a89c24a26b35f3629.tar.bz2
CUDA: Factor runtime library lookup into helper method
Diffstat (limited to 'Source')
-rw-r--r--Source/cmComputeLinkInformation.cxx39
-rw-r--r--Source/cmGeneratorTarget.cxx19
-rw-r--r--Source/cmGeneratorTarget.h3
-rw-r--r--Source/cmVisualStudioGeneratorOptions.cxx23
4 files changed, 42 insertions, 42 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/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index 7775f62..88ca92d 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -157,21 +157,14 @@ void cmVisualStudioGeneratorOptions::FixCudaRuntime(cmGeneratorTarget* target)
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");
- }
+ std::string const& cudaRuntime =
+ target->GetRuntimeLinkLibrary("CUDA", this->Configuration);
+ if (cudaRuntime == "STATIC") {
+ this->AddFlag("CudaRuntime", "Static");
+ } else if (cudaRuntime == "SHARED") {
+ this->AddFlag("CudaRuntime", "Shared");
+ } else if (cudaRuntime == "NONE") {
+ this->AddFlag("CudaRuntime", "None");
} else {
// nvcc default is static
this->AddFlag("CudaRuntime", "Static");