diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2017-12-13 16:15:06 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-12-15 15:29:20 (GMT) |
commit | 4b7618d17028da30bf0421e56aed6789bba4a12a (patch) | |
tree | e1cfaa81f14107a8988b4a0132b0d3c362d51326 /Source/cmMakefile.cxx | |
parent | 1d2d9c18bd477a6fab1744d8da13bf5d760a0e03 (diff) | |
download | CMake-4b7618d17028da30bf0421e56aed6789bba4a12a.zip CMake-4b7618d17028da30bf0421e56aed6789bba4a12a.tar.gz CMake-4b7618d17028da30bf0421e56aed6789bba4a12a.tar.bz2 |
CUDA: Fix CUDA_STANDARD selection via cxx_std_11 with CXX_STANDARD
When C++ features require a certain C++/CUDA level, verify or update the
standard level target property for each language independently.
While at it, add missing rejection of invalid `CUDA_STANDARD` property
values.
Co-Author: Brad King <brad.king@kitware.com>
Fixes: #17519
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2aaff93..a1e2f63 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4486,6 +4486,27 @@ bool cmMakefile::AddRequiredTargetCxxFeature(cmTarget* target, } } + const char* existingCudaStandard = target->GetProperty("CUDA_STANDARD"); + const char* const* existingCudaLevel = nullptr; + if (existingCudaStandard) { + existingCudaLevel = + std::find_if(cm::cbegin(CXX_STANDARDS), cm::cend(CXX_STANDARDS), + cmStrCmp(existingCudaStandard)); + if (existingCudaLevel == cm::cend(CXX_STANDARDS)) { + std::ostringstream e; + e << "The CUDA_STANDARD property on target \"" << target->GetName() + << "\" contained an invalid value: \"" << existingCudaStandard + << "\"."; + if (error) { + *error = e.str(); + } else { + this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(), + this->Backtrace); + } + return false; + } + } + /* clang-format off */ const char* const* needCxxLevel = needCxx17 ? &CXX_STANDARDS[3] @@ -4500,6 +4521,11 @@ bool cmMakefile::AddRequiredTargetCxxFeature(cmTarget* target, // the needed C++ features. if (!existingCxxLevel || existingCxxLevel < needCxxLevel) { target->SetProperty("CXX_STANDARD", *needCxxLevel); + } + + // Ensure the CUDA language level is high enough to support + // the needed C++ features. + if (!existingCudaLevel || existingCudaLevel < needCxxLevel) { target->SetProperty("CUDA_STANDARD", *needCxxLevel); } } |