瀏覽代碼

cmGeneratorTarget: Clarify local variable names for device architectures

Brad King 2 年之前
父節點
當前提交
711de9aef6
共有 1 個文件被更改,包括 20 次插入21 次删除
  1. 20 21
      Source/cmGeneratorTarget.cxx

+ 20 - 21
Source/cmGeneratorTarget.cxx

@@ -3390,9 +3390,9 @@ void cmGeneratorTarget::AddCUDAArchitectureFlags(cmBuildStep compileOrLink,
                                                  const std::string& config,
                                                  const std::string& config,
                                                  std::string& flags) const
                                                  std::string& flags) const
 {
 {
-  std::string property = this->GetSafeProperty("CUDA_ARCHITECTURES");
+  std::string arch = this->GetSafeProperty("CUDA_ARCHITECTURES");
 
 
-  if (property.empty()) {
+  if (arch.empty()) {
     switch (this->GetPolicyStatusCMP0104()) {
     switch (this->GetPolicyStatusCMP0104()) {
       case cmPolicies::WARN:
       case cmPolicies::WARN:
         if (!this->LocalGenerator->GetCMakeInstance()->GetIsInTryCompile()) {
         if (!this->LocalGenerator->GetCMakeInstance()->GetIsInTryCompile()) {
@@ -3414,7 +3414,7 @@ void cmGeneratorTarget::AddCUDAArchitectureFlags(cmBuildStep compileOrLink,
   }
   }
 
 
   // If CUDA_ARCHITECTURES is false we don't add any architectures.
   // If CUDA_ARCHITECTURES is false we don't add any architectures.
-  if (cmIsOff(property)) {
+  if (cmIsOff(arch)) {
     return;
     return;
   }
   }
 
 
@@ -3423,23 +3423,22 @@ void cmGeneratorTarget::AddCUDAArchitectureFlags(cmBuildStep compileOrLink,
   const bool ipoEnabled = this->IsIPOEnabled("CUDA", config);
   const bool ipoEnabled = this->IsIPOEnabled("CUDA", config);
 
 
   // Check for special modes: `all`, `all-major`.
   // Check for special modes: `all`, `all-major`.
-  if (property == "all" || property == "all-major") {
+  if (arch == "all" || arch == "all-major") {
     if (compiler == "NVIDIA" &&
     if (compiler == "NVIDIA" &&
         cmSystemTools::VersionCompare(
         cmSystemTools::VersionCompare(
           cmSystemTools::OP_GREATER_EQUAL,
           cmSystemTools::OP_GREATER_EQUAL,
           this->Makefile->GetDefinition("CMAKE_CUDA_COMPILER_VERSION"),
           this->Makefile->GetDefinition("CMAKE_CUDA_COMPILER_VERSION"),
           "11.5")) {
           "11.5")) {
-      flags = cmStrCat(flags, " -arch=", property);
+      flags = cmStrCat(flags, " -arch=", arch);
       return;
       return;
     }
     }
-    if (property == "all") {
-      property =
-        *this->Makefile->GetDefinition("CMAKE_CUDA_ARCHITECTURES_ALL");
-    } else if (property == "all-major") {
-      property =
+    if (arch == "all") {
+      arch = *this->Makefile->GetDefinition("CMAKE_CUDA_ARCHITECTURES_ALL");
+    } else if (arch == "all-major") {
+      arch =
         *this->Makefile->GetDefinition("CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR");
         *this->Makefile->GetDefinition("CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR");
     }
     }
-  } else if (property == "native") {
+  } else if (arch == "native") {
     cmValue native =
     cmValue native =
       this->Makefile->GetDefinition("CMAKE_CUDA_ARCHITECTURES_NATIVE");
       this->Makefile->GetDefinition("CMAKE_CUDA_ARCHITECTURES_NATIVE");
     if (native.IsEmpty()) {
     if (native.IsEmpty()) {
@@ -3452,10 +3451,10 @@ void cmGeneratorTarget::AddCUDAArchitectureFlags(cmBuildStep compileOrLink,
           cmSystemTools::OP_GREATER_EQUAL,
           cmSystemTools::OP_GREATER_EQUAL,
           this->Makefile->GetDefinition("CMAKE_CUDA_COMPILER_VERSION"),
           this->Makefile->GetDefinition("CMAKE_CUDA_COMPILER_VERSION"),
           "11.6")) {
           "11.6")) {
-      flags = cmStrCat(flags, " -arch=", property);
+      flags = cmStrCat(flags, " -arch=", arch);
       return;
       return;
     }
     }
-    property = *native;
+    arch = *native;
   }
   }
 
 
   struct CudaArchitecture
   struct CudaArchitecture
@@ -3467,7 +3466,7 @@ void cmGeneratorTarget::AddCUDAArchitectureFlags(cmBuildStep compileOrLink,
   std::vector<CudaArchitecture> architectures;
   std::vector<CudaArchitecture> architectures;
 
 
   {
   {
-    cmList options(property);
+    cmList options(arch);
 
 
     for (auto& option : options) {
     for (auto& option : options) {
       CudaArchitecture architecture;
       CudaArchitecture architecture;
@@ -3549,10 +3548,10 @@ void cmGeneratorTarget::AddCUDAArchitectureFlags(cmBuildStep compileOrLink,
 
 
 void cmGeneratorTarget::AddISPCTargetFlags(std::string& flags) const
 void cmGeneratorTarget::AddISPCTargetFlags(std::string& flags) const
 {
 {
-  const std::string& property = this->GetSafeProperty("ISPC_INSTRUCTION_SETS");
+  const std::string& arch = this->GetSafeProperty("ISPC_INSTRUCTION_SETS");
 
 
   // If ISPC_TARGET is false we don't add any architectures.
   // If ISPC_TARGET is false we don't add any architectures.
-  if (cmIsOff(property)) {
+  if (cmIsOff(arch)) {
     return;
     return;
   }
   }
 
 
@@ -3560,7 +3559,7 @@ void cmGeneratorTarget::AddISPCTargetFlags(std::string& flags) const
     this->Makefile->GetSafeDefinition("CMAKE_ISPC_COMPILER_ID");
     this->Makefile->GetSafeDefinition("CMAKE_ISPC_COMPILER_ID");
 
 
   if (compiler == "Intel") {
   if (compiler == "Intel") {
-    cmList targets(property);
+    cmList targets(arch);
     if (!targets.empty()) {
     if (!targets.empty()) {
       flags += cmStrCat(" --target=", cmWrap("", targets, "", ","));
       flags += cmStrCat(" --target=", cmWrap("", targets, "", ","));
     }
     }
@@ -3569,20 +3568,20 @@ void cmGeneratorTarget::AddISPCTargetFlags(std::string& flags) const
 
 
 void cmGeneratorTarget::AddHIPArchitectureFlags(std::string& flags) const
 void cmGeneratorTarget::AddHIPArchitectureFlags(std::string& flags) const
 {
 {
-  const std::string& property = this->GetSafeProperty("HIP_ARCHITECTURES");
+  const std::string& arch = this->GetSafeProperty("HIP_ARCHITECTURES");
 
 
-  if (property.empty()) {
+  if (arch.empty()) {
     this->Makefile->IssueMessage(MessageType::FATAL_ERROR,
     this->Makefile->IssueMessage(MessageType::FATAL_ERROR,
                                  "HIP_ARCHITECTURES is empty for target \"" +
                                  "HIP_ARCHITECTURES is empty for target \"" +
                                    this->GetName() + "\".");
                                    this->GetName() + "\".");
   }
   }
 
 
   // If HIP_ARCHITECTURES is false we don't add any architectures.
   // If HIP_ARCHITECTURES is false we don't add any architectures.
-  if (cmIsOff(property)) {
+  if (cmIsOff(arch)) {
     return;
     return;
   }
   }
 
 
-  cmList options(property);
+  cmList options(arch);
 
 
   for (std::string& option : options) {
   for (std::string& option : options) {
     flags += " --offload-arch=" + option;
     flags += " --offload-arch=" + option;