diff options
author | Cristian Le <cristian.le@mpsd.mpg.de> | 2023-10-16 14:25:11 (GMT) |
---|---|---|
committer | Cristian Le <cristian.le@mpsd.mpg.de> | 2023-10-18 11:39:55 (GMT) |
commit | 704acca96bcdf30c15bb64f2b7a92c21decc46ee (patch) | |
tree | 9aeae8d74b2688ae5a01738a737cfd9111a6232a /Source/cmProjectCommand.cxx | |
parent | 7144216f45c402b68ec8d7b5e8050b6536a199aa (diff) | |
download | CMake-704acca96bcdf30c15bb64f2b7a92c21decc46ee.zip CMake-704acca96bcdf30c15bb64f2b7a92c21decc46ee.tar.gz CMake-704acca96bcdf30c15bb64f2b7a92c21decc46ee.tar.bz2 |
CMAKE_PROJECT_INCLUDE: Add support for including multiple files
Fixes: #25341
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
Diffstat (limited to 'Source/cmProjectCommand.cxx')
-rw-r--r-- | Source/cmProjectCommand.cxx | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 3aef299..bb5f522 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -11,6 +11,7 @@ #include "cmsys/RegularExpression.hxx" #include "cmExecutionStatus.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmMessageType.h" #include "cmPolicies.h" @@ -371,29 +372,41 @@ static bool IncludeByVariable(cmExecutionStatus& status, if (!include) { return true; } + cmList includeFiles{ *include }; + + bool failed = false; + for (auto const& filePath : includeFiles) { + std::string includeFile = cmSystemTools::CollapseFullPath( + filePath, mf.GetCurrentSourceDirectory()); + if (!cmSystemTools::FileExists(includeFile)) { + status.SetError( + cmStrCat("could not find requested file:\n ", filePath)); + failed = true; + continue; + } + if (cmSystemTools::FileIsDirectory(includeFile)) { + status.SetError( + cmStrCat("requested file is a directory:\n ", filePath)); + failed = true; + continue; + } - std::string includeFile = - cmSystemTools::CollapseFullPath(*include, mf.GetCurrentSourceDirectory()); - if (!cmSystemTools::FileExists(includeFile)) { - status.SetError(cmStrCat("could not find requested file:\n ", *include)); - return false; - } - if (cmSystemTools::FileIsDirectory(includeFile)) { - status.SetError(cmStrCat("requested file is a directory:\n ", *include)); - return false; - } + const bool readit = mf.ReadDependentFile(filePath); + if (readit) { + // If the included file ran successfully, continue to the next file + continue; + } - const bool readit = mf.ReadDependentFile(*include); - if (readit) { - return true; - } + if (cmSystemTools::GetFatalErrorOccurred()) { + failed = true; + continue; + } - if (cmSystemTools::GetFatalErrorOccurred()) { - return true; + status.SetError(cmStrCat("could not load requested file:\n ", filePath)); + failed = true; } - - status.SetError(cmStrCat("could not load requested file:\n ", *include)); - return false; + // At this point all files were processed + return !failed; } static void TopLevelCMakeVarCondSet(cmMakefile& mf, std::string const& name, |