summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefileTargetGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-03-14 13:34:42 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-03-14 13:35:00 (GMT)
commitdb4f4ad24e9a0ec8e0cb22b6b0204173d06e1cf8 (patch)
tree371c95db87ee1b9956ad84fd9f889196d027dc60 /Source/cmMakefileTargetGenerator.cxx
parent9b68949a27e6962423fb75296b06f4d6d1e6cf73 (diff)
parent2def6a874b52ef70157f101cbca9ee9b92a5a7f5 (diff)
downloadCMake-db4f4ad24e9a0ec8e0cb22b6b0204173d06e1cf8.zip
CMake-db4f4ad24e9a0ec8e0cb22b6b0204173d06e1cf8.tar.gz
CMake-db4f4ad24e9a0ec8e0cb22b6b0204173d06e1cf8.tar.bz2
Merge topic 'support_cubin_fatbin_optix_cuda_output'
2def6a874b CUDA: Add support for CUBIN, FATBIN, and OPTIXIR compilation Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !8259
Diffstat (limited to 'Source/cmMakefileTargetGenerator.cxx')
-rw-r--r--Source/cmMakefileTargetGenerator.cxx23
1 files changed, 18 insertions, 5 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index e217dd9..2ead739 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -3,6 +3,7 @@
#include "cmMakefileTargetGenerator.h"
#include <algorithm>
+#include <array>
#include <cassert>
#include <cstdio>
#include <iterator>
@@ -977,11 +978,23 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
this->Makefile->GetRequiredDefinition("_CMAKE_CUDA_RDC_FLAG");
cudaCompileMode = cmStrCat(cudaCompileMode, rdcFlag, " ");
}
- if (this->GeneratorTarget->GetPropertyAsBool("CUDA_PTX_COMPILATION")) {
- const std::string& ptxFlag =
- this->Makefile->GetRequiredDefinition("_CMAKE_CUDA_PTX_FLAG");
- cudaCompileMode = cmStrCat(cudaCompileMode, ptxFlag);
- } else {
+
+ static std::array<cm::string_view, 4> const compileModes{
+ { "PTX"_s, "CUBIN"_s, "FATBIN"_s, "OPTIX"_s }
+ };
+ bool useNormalCompileMode = true;
+ for (cm::string_view mode : compileModes) {
+ auto propName = cmStrCat("CUDA_", mode, "_COMPILATION");
+ auto defName = cmStrCat("_CMAKE_CUDA_", mode, "_FLAG");
+ if (this->GeneratorTarget->GetPropertyAsBool(propName)) {
+ const std::string& flag =
+ this->Makefile->GetRequiredDefinition(defName);
+ cudaCompileMode = cmStrCat(cudaCompileMode, flag);
+ useNormalCompileMode = false;
+ break;
+ }
+ }
+ if (useNormalCompileMode) {
const std::string& wholeFlag =
this->Makefile->GetRequiredDefinition("_CMAKE_CUDA_WHOLE_FLAG");
cudaCompileMode = cmStrCat(cudaCompileMode, wholeFlag);