diff options
author | Robert Maynard <rmaynard@nvidia.com> | 2023-01-27 20:46:19 (GMT) |
---|---|---|
committer | Robert Maynard <rmaynard@nvidia.com> | 2023-03-13 13:54:00 (GMT) |
commit | 2def6a874b52ef70157f101cbca9ee9b92a5a7f5 (patch) | |
tree | f08dda163a1d8af66c4ce780cae0875ec2a4696f /Source/cmGeneratorTarget.cxx | |
parent | 7b37ebe8357d9b1e2a5c97b58c9f2f5b690d163e (diff) | |
download | CMake-2def6a874b52ef70157f101cbca9ee9b92a5a7f5.zip CMake-2def6a874b52ef70157f101cbca9ee9b92a5a7f5.tar.gz CMake-2def6a874b52ef70157f101cbca9ee9b92a5a7f5.tar.bz2 |
CUDA: Add support for CUBIN, FATBIN, and OPTIXIR compilation
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index cfb2887..112a87f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3,6 +3,7 @@ #include "cmGeneratorTarget.h" #include <algorithm> +#include <array> #include <cassert> #include <cerrno> #include <cstddef> @@ -1000,12 +1001,27 @@ const std::string& cmGeneratorTarget::GetObjectName(cmSourceFile const* file) const char* cmGeneratorTarget::GetCustomObjectExtension() const { - static std::string extension; - const bool has_ptx_extension = - this->GetPropertyAsBool("CUDA_PTX_COMPILATION"); - if (has_ptx_extension) { - extension = ".ptx"; - return extension.c_str(); + struct compiler_mode + { + std::string variable; + std::string extension; + }; + static std::array<compiler_mode, 4> const modes{ + { { "CUDA_PTX_COMPILATION", ".ptx" }, + { "CUDA_CUBIN_COMPILATION", ".cubin" }, + { "CUDA_FATBIN_COMPILATION", ".fatbin" }, + { "CUDA_OPTIX_COMPILATION", ".optixir" } } + }; + + std::string const& compiler = + this->Makefile->GetSafeDefinition("CMAKE_CUDA_COMPILER_ID"); + if (!compiler.empty()) { + for (const auto& m : modes) { + const bool has_extension = this->GetPropertyAsBool(m.variable); + if (has_extension) { + return m.extension.c_str(); + } + } } return nullptr; } |