summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorRaul Tambre <raul@tambre.ee>2020-06-12 16:59:32 (GMT)
committerBrad King <brad.king@kitware.com>2020-06-15 13:13:32 (GMT)
commit877a92e968bfa24d86f4b9685b5c27d4c9e6c1be (patch)
tree3c410caeece84452eff2f1ef27eb01b5b1b54f1f /Source
parent594fda9c234915669dbfe61bec7c59250e747b4a (diff)
downloadCMake-877a92e968bfa24d86f4b9685b5c27d4c9e6c1be.zip
CMake-877a92e968bfa24d86f4b9685b5c27d4c9e6c1be.tar.gz
CMake-877a92e968bfa24d86f4b9685b5c27d4c9e6c1be.tar.bz2
CUDA: Add support for disabling CUDA_ARCHITECTURES
The ability to disable adding architectures completely for packaging purposes and cases requiring passing the architectures flags explicitly has been requested. Support a false value for CUDA_ARCHITECTURES and CMAKE_CUDA_ARCHITECTURES for this purpose. Implements #20821.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorTarget.cxx51
1 files changed, 29 insertions, 22 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 250910a..54d34ba 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -3044,6 +3044,34 @@ void cmGeneratorTarget::GetAppleArchs(const std::string& config,
void cmGeneratorTarget::AddCUDAArchitectureFlags(std::string& flags) const
{
+ const std::string& property = this->GetSafeProperty("CUDA_ARCHITECTURES");
+
+ if (property.empty()) {
+ switch (this->GetPolicyStatusCMP0104()) {
+ case cmPolicies::WARN:
+ if (!this->LocalGenerator->GetCMakeInstance()->GetIsInTryCompile()) {
+ this->Makefile->IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmPolicies::GetPolicyWarning(cmPolicies::CMP0104) +
+ "\nCUDA_ARCHITECTURES is empty for target \"" + this->GetName() +
+ "\".");
+ }
+ CM_FALLTHROUGH;
+ case cmPolicies::OLD:
+ break;
+ default:
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ "CUDA_ARCHITECTURES is empty for target \"" + this->GetName() +
+ "\".");
+ }
+ }
+
+ // If CUDA_ARCHITECTURES is false we don't add any architectures.
+ if (cmIsOff(property)) {
+ return;
+ }
+
struct CudaArchitecture
{
std::string name;
@@ -3054,28 +3082,7 @@ void cmGeneratorTarget::AddCUDAArchitectureFlags(std::string& flags) const
{
std::vector<std::string> options;
- cmExpandList(this->GetSafeProperty("CUDA_ARCHITECTURES"), options);
-
- if (options.empty()) {
- switch (this->GetPolicyStatusCMP0104()) {
- case cmPolicies::WARN:
- if (!this->LocalGenerator->GetCMakeInstance()->GetIsInTryCompile()) {
- this->Makefile->IssueMessage(
- MessageType::AUTHOR_WARNING,
- cmPolicies::GetPolicyWarning(cmPolicies::CMP0104) +
- "\nCUDA_ARCHITECTURES is empty for target \"" +
- this->GetName() + "\".");
- }
- CM_FALLTHROUGH;
- case cmPolicies::OLD:
- break;
- default:
- this->Makefile->IssueMessage(
- MessageType::FATAL_ERROR,
- "CUDA_ARCHITECTURES is empty for target \"" + this->GetName() +
- "\".");
- }
- }
+ cmExpandList(property, options);
for (std::string& option : options) {
CudaArchitecture architecture;