|
@@ -2,6 +2,7 @@
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
|
|
#include "cmVisualStudio10TargetGenerator.h"
|
|
#include "cmVisualStudio10TargetGenerator.h"
|
|
|
|
|
|
|
|
|
|
+#include "cmAlgorithms.h"
|
|
|
#include "cmComputeLinkInformation.h"
|
|
#include "cmComputeLinkInformation.h"
|
|
|
#include "cmCustomCommandGenerator.h"
|
|
#include "cmCustomCommandGenerator.h"
|
|
|
#include "cmGeneratedFileStream.h"
|
|
#include "cmGeneratedFileStream.h"
|
|
@@ -2227,10 +2228,27 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
|
|
|
this->Name.c_str());
|
|
this->Name.c_str());
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
- if (linkLanguage == "C" || linkLanguage == "CXX" ||
|
|
|
|
|
- linkLanguage == "Fortran" || linkLanguage == "CSharp") {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // Choose a language whose flags to use for ClCompile.
|
|
|
|
|
+ static const char* clLangs[] = { "CXX", "C", "Fortran", "CSharp" };
|
|
|
|
|
+ std::string langForClCompile;
|
|
|
|
|
+ if (std::find(cmArrayBegin(clLangs), cmArrayEnd(clLangs), linkLanguage) !=
|
|
|
|
|
+ cmArrayEnd(clLangs)) {
|
|
|
|
|
+ langForClCompile = linkLanguage;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ std::set<std::string> languages;
|
|
|
|
|
+ this->GeneratorTarget->GetLanguages(languages, configName);
|
|
|
|
|
+ for (const char* const* l = cmArrayBegin(clLangs);
|
|
|
|
|
+ l != cmArrayEnd(clLangs); ++l) {
|
|
|
|
|
+ if (languages.find(*l) != languages.end()) {
|
|
|
|
|
+ langForClCompile = *l;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!langForClCompile.empty()) {
|
|
|
std::string baseFlagVar = "CMAKE_";
|
|
std::string baseFlagVar = "CMAKE_";
|
|
|
- baseFlagVar += linkLanguage;
|
|
|
|
|
|
|
+ baseFlagVar += langForClCompile;
|
|
|
baseFlagVar += "_FLAGS";
|
|
baseFlagVar += "_FLAGS";
|
|
|
flags =
|
|
flags =
|
|
|
this->GeneratorTarget->Target->GetMakefile()->GetRequiredDefinition(
|
|
this->GeneratorTarget->Target->GetMakefile()->GetRequiredDefinition(
|
|
@@ -2241,6 +2259,8 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
|
|
|
flags +=
|
|
flags +=
|
|
|
this->GeneratorTarget->Target->GetMakefile()->GetRequiredDefinition(
|
|
this->GeneratorTarget->Target->GetMakefile()->GetRequiredDefinition(
|
|
|
flagVar.c_str());
|
|
flagVar.c_str());
|
|
|
|
|
+ this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget,
|
|
|
|
|
+ langForClCompile, configName);
|
|
|
}
|
|
}
|
|
|
// set the correct language
|
|
// set the correct language
|
|
|
if (linkLanguage == "C") {
|
|
if (linkLanguage == "C") {
|
|
@@ -2249,10 +2269,6 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
|
|
|
if (linkLanguage == "CXX") {
|
|
if (linkLanguage == "CXX") {
|
|
|
clOptions.AddFlag("CompileAs", "CompileAsCpp");
|
|
clOptions.AddFlag("CompileAs", "CompileAsCpp");
|
|
|
}
|
|
}
|
|
|
- if (linkLanguage != "CUDA") {
|
|
|
|
|
- this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget,
|
|
|
|
|
- linkLanguage, configName.c_str());
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
// Check IPO related warning/error.
|
|
// Check IPO related warning/error.
|
|
|
this->GeneratorTarget->IsIPOEnabled(linkLanguage, configName);
|
|
this->GeneratorTarget->IsIPOEnabled(linkLanguage, configName);
|
|
@@ -2480,6 +2496,8 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
|
|
|
std::string(this->Makefile->GetSafeDefinition("CMAKE_CUDA_FLAGS")) +
|
|
std::string(this->Makefile->GetSafeDefinition("CMAKE_CUDA_FLAGS")) +
|
|
|
std::string(" ") +
|
|
std::string(" ") +
|
|
|
std::string(this->Makefile->GetSafeDefinition(configFlagsVar));
|
|
std::string(this->Makefile->GetSafeDefinition(configFlagsVar));
|
|
|
|
|
+ this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, "CUDA",
|
|
|
|
|
+ configName);
|
|
|
|
|
|
|
|
// Get preprocessor definitions for this directory.
|
|
// Get preprocessor definitions for this directory.
|
|
|
std::string defineFlags =
|
|
std::string defineFlags =
|