diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2023-11-18 03:50:14 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2023-11-21 14:43:17 (GMT) |
commit | c1fc5455b192e2791010c4bec20b300c7652b712 (patch) | |
tree | cfcf00f2b8a637ad0f336fb673ed975df200fbe9 /Source | |
parent | 515ca5fcd16f97c9f0a516046dfe22ecfc9676c4 (diff) | |
download | CMake-c1fc5455b192e2791010c4bec20b300c7652b712.zip CMake-c1fc5455b192e2791010c4bec20b300c7652b712.tar.gz CMake-c1fc5455b192e2791010c4bec20b300c7652b712.tar.bz2 |
cmGeneratorTarget: also check included objects for Fortran modules
Fortran modules provided by objects in `$<TARGET_OBJECTS>` should also
count as "has Fortran modules" for the target referencing the objects.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 29d2af3..146319a 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -9090,19 +9090,47 @@ std::string cmGeneratorTarget::GetImportedXcFrameworkPath( bool cmGeneratorTarget::HaveFortranSources(std::string const& config) const { auto sources = this->GetSourceFiles(config); - return std::any_of(sources.begin(), sources.end(), - [](BT<cmSourceFile*> const& sf) -> bool { - return sf.Value->GetLanguage() == "Fortran"_s; - }); + bool const have_direct = std::any_of( + sources.begin(), sources.end(), [](BT<cmSourceFile*> const& sf) -> bool { + return sf.Value->GetLanguage() == "Fortran"_s; + }); + bool have_via_target_objects = false; + if (!have_direct) { + auto const sourceObjectLibraries = this->GetSourceObjectLibraries(config); + have_via_target_objects = + std::any_of(sourceObjectLibraries.begin(), sourceObjectLibraries.end(), + [&config](cmGeneratorTarget const* tgt) -> bool { + return tgt->HaveFortranSources(config); + }); + } + return have_direct || have_via_target_objects; } bool cmGeneratorTarget::HaveFortranSources() const { - auto sources = cmGeneratorTarget::GetAllConfigSources(); - return std::any_of(sources.begin(), sources.end(), - [](AllConfigSource const& sf) -> bool { - return sf.Source->GetLanguage() == "Fortran"_s; - }); + auto sources = this->GetAllConfigSources(); + bool const have_direct = std::any_of( + sources.begin(), sources.end(), [](AllConfigSource const& sf) -> bool { + return sf.Source->GetLanguage() == "Fortran"_s; + }); + bool have_via_target_objects = false; + if (!have_direct) { + std::vector<std::string> configs = + this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); + for (auto const& config : configs) { + auto const sourceObjectLibraries = + this->GetSourceObjectLibraries(config); + have_via_target_objects = + std::any_of(sourceObjectLibraries.begin(), sourceObjectLibraries.end(), + [&config](cmGeneratorTarget const* tgt) -> bool { + return tgt->HaveFortranSources(config); + }); + if (have_via_target_objects) { + break; + } + } + } + return have_direct || have_via_target_objects; } bool cmGeneratorTarget::HaveCxx20ModuleSources(std::string* errorMessage) const |