mirror of
https://github.com/reactos/CMake.git
synced 2024-11-27 05:20:34 +00:00
CUDA: Factor runtime library lookup into helper method
This commit is contained in:
parent
fa6db3738a
commit
4468acb979
@ -12,7 +12,6 @@
|
||||
#include <cmext/algorithm>
|
||||
|
||||
#include "cmComputeLinkDepends.h"
|
||||
#include "cmGeneratorExpression.h"
|
||||
#include "cmGeneratorTarget.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmListFileCache.h"
|
||||
@ -587,26 +586,14 @@ 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 const& runtimeLibrary =
|
||||
this->Target->GetRuntimeLinkLibrary(lang, this->Config);
|
||||
if (runtimeLibrary.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
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)) {
|
||||
"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)) {
|
||||
@ -614,8 +601,6 @@ void cmComputeLinkInformation::AddRuntimeLinkLibrary(std::string const& lang)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang)
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
std::string const& cudaRuntime =
|
||||
target->GetRuntimeLinkLibrary("CUDA", this->Configuration);
|
||||
if (cudaRuntime == "STATIC") {
|
||||
this->AddFlag("CudaRuntime", "Static");
|
||||
}
|
||||
if (cudaRuntime == "SHARED") {
|
||||
} else if (cudaRuntime == "SHARED") {
|
||||
this->AddFlag("CudaRuntime", "Shared");
|
||||
}
|
||||
if (cudaRuntime == "NONE") {
|
||||
} else if (cudaRuntime == "NONE") {
|
||||
this->AddFlag("CudaRuntime", "None");
|
||||
}
|
||||
} else {
|
||||
// nvcc default is static
|
||||
this->AddFlag("CudaRuntime", "Static");
|
||||
|
Loading…
Reference in New Issue
Block a user