diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2023-07-23 17:36:53 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2023-08-16 14:40:11 (GMT) |
commit | 1690e451f7a640fbdd7bc693ea8010ebc52639bc (patch) | |
tree | 93b167a29787193276cb97146b889920ebc11fc0 /Source/cmGeneratorTarget.cxx | |
parent | 58d27dc6dbdc1cd2dcc537c95b2810528228d754 (diff) | |
download | CMake-1690e451f7a640fbdd7bc693ea8010ebc52639bc.zip CMake-1690e451f7a640fbdd7bc693ea8010ebc52639bc.tar.gz CMake-1690e451f7a640fbdd7bc693ea8010ebc52639bc.tar.bz2 |
cmGeneratorTarget: support better errors when checking for C++20 modules
Some callers have their own error reporting mechanisms which give more
context. Support handing off the error string for these use cases.
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index eb4ba90..c6b2718 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -8930,24 +8930,28 @@ bool cmGeneratorTarget::HaveFortranSources(std::string const& config) const }); } -bool cmGeneratorTarget::HaveCxx20ModuleSources() const +bool cmGeneratorTarget::HaveCxx20ModuleSources(std::string* errorMessage) const { auto const& fs_names = this->Target->GetAllFileSetNames(); - return std::any_of(fs_names.begin(), fs_names.end(), - [this](std::string const& name) -> bool { - auto const* file_set = this->Target->GetFileSet(name); - if (!file_set) { - this->Makefile->IssueMessage( - MessageType::INTERNAL_ERROR, - cmStrCat("Target \"", this->Target->GetName(), - "\" is tracked to have file set \"", name, - "\", but it was not found.")); - return false; - } - - auto const& fs_type = file_set->GetType(); - return fs_type == "CXX_MODULES"_s; - }); + return std::any_of( + fs_names.begin(), fs_names.end(), + [this, errorMessage](std::string const& name) -> bool { + auto const* file_set = this->Target->GetFileSet(name); + if (!file_set) { + auto message = cmStrCat("Target \"", this->Target->GetName(), + "\" is tracked to have file set \"", name, + "\", but it was not found."); + if (errorMessage) { + *errorMessage = std::move(message); + } else { + this->Makefile->IssueMessage(MessageType::INTERNAL_ERROR, message); + } + return false; + } + + auto const& fs_type = file_set->GetType(); + return fs_type == "CXX_MODULES"_s; + }); } cmGeneratorTarget::Cxx20SupportLevel cmGeneratorTarget::HaveCxxModuleSupport( |