From fe64c49e72ec025965bc9fe1a733859c025f68b1 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 28 Feb 2022 13:23:14 -0500 Subject: CUDA: Simplify CMAKE_CUDA_ARCHITECTURES special value logic Refactor the logic checking `CMAKE_CUDA_ARCHITECTURES` special values. Switch on the value first, and then make other decisions for each case. This makes room for other special values to be added later. --- Source/cmGeneratorTarget.cxx | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'Source/cmGeneratorTarget.cxx') diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index afcac5cbcb..63cf2ec0ea 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3447,22 +3447,22 @@ void cmGeneratorTarget::AddCUDAArchitectureFlags(std::string& flags) const this->Makefile->GetSafeDefinition("CMAKE_CUDA_COMPILER_ID"); // Check for special modes: `all`, `all-major`. - if (compiler == "NVIDIA" && - cmSystemTools::VersionCompare( - cmSystemTools::OP_GREATER_EQUAL, - this->Makefile->GetDefinition("CMAKE_CUDA_COMPILER_VERSION"), - "11.5")) { - if (property == "all" || property == "all-major") { + if (property == "all" || property == "all-major") { + if (compiler == "NVIDIA" && + cmSystemTools::VersionCompare( + cmSystemTools::OP_GREATER_EQUAL, + this->Makefile->GetDefinition("CMAKE_CUDA_COMPILER_VERSION"), + "11.5")) { flags = cmStrCat(flags, " -arch=", property); return; } - } - - if (property == "all") { - property = *this->Makefile->GetDefinition("CMAKE_CUDA_ARCHITECTURES_ALL"); - } else if (property == "all-major") { - property = - *this->Makefile->GetDefinition("CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR"); + if (property == "all") { + property = + *this->Makefile->GetDefinition("CMAKE_CUDA_ARCHITECTURES_ALL"); + } else if (property == "all-major") { + property = + *this->Makefile->GetDefinition("CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR"); + } } struct CudaArchitecture -- cgit v1.2.1