summaryrefslogtreecommitdiffstats
path: root/Source/cmVisualStudioGeneratorOptions.cxx
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2019-11-29 18:51:32 (GMT)
committerRobert Maynard <robert.maynard@kitware.com>2020-01-27 21:02:26 (GMT)
commit0d0145138fe7cd60edc7f0b97e860e9a4fae1555 (patch)
treec013d23f71ec3e8b0e1ccbb632d3cbb0a560d91d /Source/cmVisualStudioGeneratorOptions.cxx
parent4dbc9dfc7a1458878a26e1f0cec1a382e14bf48a (diff)
downloadCMake-0d0145138fe7cd60edc7f0b97e860e9a4fae1555.zip
CMake-0d0145138fe7cd60edc7f0b97e860e9a4fae1555.tar.gz
CMake-0d0145138fe7cd60edc7f0b97e860e9a4fae1555.tar.bz2
CUDA: Add abstraction for cuda runtime selection
Fixes #17559 Replace our hard-coded default of cudart=static with a first-class abstraction to select the runtime library from an enumeration of logical names.
Diffstat (limited to 'Source/cmVisualStudioGeneratorOptions.cxx')
-rw-r--r--Source/cmVisualStudioGeneratorOptions.cxx38
1 files changed, 24 insertions, 14 deletions
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index 18c19b7..4004b66 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -3,6 +3,8 @@
#include <cm/iterator>
#include "cmAlgorithms.h"
+#include "cmGeneratorExpression.h"
+#include "cmGeneratorTarget.h"
#include "cmLocalVisualStudioGenerator.h"
#include "cmOutputConverter.h"
#include "cmSystemTools.h"
@@ -149,25 +151,33 @@ bool cmVisualStudioGeneratorOptions::UsingSBCS() const
return false;
}
-cmVisualStudioGeneratorOptions::CudaRuntime
-cmVisualStudioGeneratorOptions::GetCudaRuntime() const
+void cmVisualStudioGeneratorOptions::FixCudaRuntime(cmGeneratorTarget* target)
{
std::map<std::string, FlagValue>::const_iterator i =
this->FlagMap.find("CudaRuntime");
- if (i != this->FlagMap.end() && i->second.size() == 1) {
- std::string const& cudaRuntime = i->second[0];
- if (cudaRuntime == "Static") {
- return CudaRuntimeStatic;
- }
- if (cudaRuntime == "Shared") {
- return CudaRuntimeShared;
- }
- if (cudaRuntime == "None") {
- return CudaRuntimeNone;
+ if (i == this->FlagMap.end()) {
+ // User didn't provide am override so get the property value
+ const char* 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");
}
}
- // nvcc default is static
- return CudaRuntimeStatic;
}
void cmVisualStudioGeneratorOptions::FixCudaCodeGeneration()