summaryrefslogtreecommitdiffstats
path: root/Source/cmCoreTryCompile.cxx
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2016-12-02 21:56:12 (GMT)
committerRobert Maynard <robert.maynard@kitware.com>2016-12-12 19:39:32 (GMT)
commit1371eec4c38b0a3b83f1416774c6c213ad0db6fc (patch)
tree7cdc524fe87bc18ddeb67f923f639881e1f0c07e /Source/cmCoreTryCompile.cxx
parent3d3d3f94703e23d3d2cbff67537057474e3e0ff1 (diff)
downloadCMake-1371eec4c38b0a3b83f1416774c6c213ad0db6fc.zip
CMake-1371eec4c38b0a3b83f1416774c6c213ad0db6fc.tar.gz
CMake-1371eec4c38b0a3b83f1416774c6c213ad0db6fc.tar.bz2
try_compile: extend CMP0067 to honor language standards for CUDA.
Diffstat (limited to 'Source/cmCoreTryCompile.cxx')
-rw-r--r--Source/cmCoreTryCompile.cxx79
1 files changed, 77 insertions, 2 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index f12c9e8..ff9ffc0 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -108,10 +108,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
std::string copyFileError;
std::string cStandard;
std::string cxxStandard;
+ std::string cudaStandard;
std::string cStandardRequired;
std::string cxxStandardRequired;
+ std::string cudaStandardRequired;
std::string cExtensions;
std::string cxxExtensions;
+ std::string cudaExtensions;
std::vector<std::string> targets;
std::string libsToLink = " ";
bool useOldLinkLibs = true;
@@ -121,10 +124,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
bool didCopyFileError = false;
bool didCStandard = false;
bool didCxxStandard = false;
+ bool didCudaStandard = false;
bool didCStandardRequired = false;
bool didCxxStandardRequired = false;
+ bool didCudaStandardRequired = false;
bool didCExtensions = false;
bool didCxxExtensions = false;
+ bool didCudaExtensions = false;
bool useSources = argv[2] == "SOURCES";
std::vector<std::string> sources;
@@ -139,10 +145,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
DoingCopyFileError,
DoingCStandard,
DoingCxxStandard,
+ DoingCudaStandard,
DoingCStandardRequired,
DoingCxxStandardRequired,
+ DoingCudaStandardRequired,
DoingCExtensions,
DoingCxxExtensions,
+ DoingCudaExtensions,
DoingSources
};
Doing doing = useSources ? DoingSources : DoingNone;
@@ -169,18 +178,27 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
} else if (argv[i] == "CXX_STANDARD") {
doing = DoingCxxStandard;
didCxxStandard = true;
+ } else if (argv[i] == "CUDA_STANDARD") {
+ doing = DoingCudaStandard;
+ didCudaStandard = true;
} else if (argv[i] == "C_STANDARD_REQUIRED") {
doing = DoingCStandardRequired;
didCStandardRequired = true;
} else if (argv[i] == "CXX_STANDARD_REQUIRED") {
doing = DoingCxxStandardRequired;
didCxxStandardRequired = true;
+ } else if (argv[i] == "CUDA_STANDARD_REQUIRED") {
+ doing = DoingCudaStandardRequired;
+ didCudaStandardRequired = true;
} else if (argv[i] == "C_EXTENSIONS") {
doing = DoingCExtensions;
didCExtensions = true;
} else if (argv[i] == "CXX_EXTENSIONS") {
doing = DoingCxxExtensions;
didCxxExtensions = true;
+ } else if (argv[i] == "CUDA_EXTENSIONS") {
+ doing = DoingCudaExtensions;
+ didCudaExtensions = true;
} else if (doing == DoingCMakeFlags) {
cmakeFlags.push_back(argv[i]);
} else if (doing == DoingCompileDefinitions) {
@@ -227,18 +245,27 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
} else if (doing == DoingCxxStandard) {
cxxStandard = argv[i];
doing = DoingNone;
+ } else if (doing == DoingCudaStandard) {
+ cudaStandard = argv[i];
+ doing = DoingNone;
} else if (doing == DoingCStandardRequired) {
cStandardRequired = argv[i];
doing = DoingNone;
} else if (doing == DoingCxxStandardRequired) {
cxxStandardRequired = argv[i];
doing = DoingNone;
+ } else if (doing == DoingCudaStandardRequired) {
+ cudaStandardRequired = argv[i];
+ doing = DoingNone;
} else if (doing == DoingCExtensions) {
cExtensions = argv[i];
doing = DoingNone;
} else if (doing == DoingCxxExtensions) {
cxxExtensions = argv[i];
doing = DoingNone;
+ } else if (doing == DoingCudaExtensions) {
+ cudaExtensions = argv[i];
+ doing = DoingNone;
} else if (doing == DoingSources) {
sources.push_back(argv[i]);
} else if (i == 3) {
@@ -297,6 +324,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
"CXX_STANDARD allowed only in source file signature.");
return -1;
}
+ if (didCudaStandard && !this->SrcFileSignature) {
+ this->Makefile->IssueMessage(
+ cmake::FATAL_ERROR,
+ "CUDA_STANDARD allowed only in source file signature.");
+ return -1;
+ }
if (didCStandardRequired && !this->SrcFileSignature) {
this->Makefile->IssueMessage(
cmake::FATAL_ERROR,
@@ -309,6 +342,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
"CXX_STANDARD_REQUIRED allowed only in source file signature.");
return -1;
}
+ if (didCudaStandardRequired && !this->SrcFileSignature) {
+ this->Makefile->IssueMessage(
+ cmake::FATAL_ERROR,
+ "CUDA_STANDARD_REQUIRED allowed only in source file signature.");
+ return -1;
+ }
if (didCExtensions && !this->SrcFileSignature) {
this->Makefile->IssueMessage(
cmake::FATAL_ERROR,
@@ -321,6 +360,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
"CXX_EXTENSIONS allowed only in source file signature.");
return -1;
}
+ if (didCudaExtensions && !this->SrcFileSignature) {
+ this->Makefile->IssueMessage(
+ cmake::FATAL_ERROR,
+ "CUDA_EXTENSIONS allowed only in source file signature.");
+ return -1;
+ }
// compute the binary dir when TRY_COMPILE is called with a src file
// signature
@@ -630,12 +675,15 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
bool const testC = testLangs.find("C") != testLangs.end();
bool const testCxx = testLangs.find("CXX") != testLangs.end();
+ bool const testCuda = testLangs.find("CUDA") != testLangs.end();
bool warnCMP0067 = false;
bool honorStandard = true;
- if (!didCStandard && !didCxxStandard && !didCStandardRequired &&
- !didCxxStandardRequired && !didCExtensions && !didCxxExtensions) {
+ if (!didCStandard && !didCxxStandard && !didCudaStandard &&
+ !didCStandardRequired && !didCxxStandardRequired &&
+ !didCudaStandardRequired && !didCExtensions && !didCxxExtensions &&
+ !didCudaExtensions) {
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0067)) {
case cmPolicies::WARN:
warnCMP0067 = this->Makefile->PolicyOptionalWarningEnabled(
@@ -682,6 +730,20 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
this->LookupStdVar("CMAKE_CXX_EXTENSIONS", warnCMP0067);
}
}
+ if (testCuda) {
+ if (!didCudaStandard) {
+ cudaStandard =
+ this->LookupStdVar("CMAKE_CUDA_STANDARD", warnCMP0067);
+ }
+ if (!didCudaStandardRequired) {
+ cudaStandardRequired =
+ this->LookupStdVar("CMAKE_CUDA_STANDARD_REQUIRED", warnCMP0067);
+ }
+ if (!didCudaExtensions) {
+ cudaExtensions =
+ this->LookupStdVar("CMAKE_CUDA_EXTENSIONS", warnCMP0067);
+ }
+ }
}
if (!this->WarnCMP0067.empty()) {
@@ -725,6 +787,19 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
}
}
+ if (testCuda) {
+ if (!cudaStandard.empty()) {
+ writeProperty(fout, targetName, "CUDA_STANDARD", cudaStandard);
+ }
+ if (!cudaStandardRequired.empty()) {
+ writeProperty(fout, targetName, "CUDA_STANDARD_REQUIRED",
+ cudaStandardRequired);
+ }
+ if (!cudaExtensions.empty()) {
+ writeProperty(fout, targetName, "CUDA_EXTENSIONS", cudaExtensions);
+ }
+ }
+
if (useOldLinkLibs) {
fprintf(fout, "target_link_libraries(%s ${LINK_LIBRARIES})\n",
targetName.c_str());