mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-27 09:29:15 -05:00
Merge topic 'cmake-presets-include-outside-project-dir'
0c2d234bc9 CMakePresets: Allow files included from CMakePresets.json to be anywhere
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Gerhard Olsson <gerhard.nospam@gmail.com>
Merge-request: !6867
This commit is contained in:
@@ -37,10 +37,9 @@ a file may be included multiple times from the same file or from different
|
||||
files. If ``CMakePresets.json`` and ``CMakeUserPresets.json`` are both present,
|
||||
``CMakeUserPresets.json`` implicitly includes ``CMakePresets.json``, even with
|
||||
no ``include`` field, in all versions of the format. Files directly or
|
||||
indirectly included from ``CMakePresets.json`` must be inside the project
|
||||
directory. This restriction does not apply to ``CMakeUserPresets.json`` and
|
||||
files that it includes, unless those files are also included by
|
||||
``CMakePresets.json``.
|
||||
indirectly included from ``CMakePresets.json`` should be guaranteed to be
|
||||
provided by the project. ``CMakeUserPresets.json`` may include files from
|
||||
anywhere.
|
||||
|
||||
Format
|
||||
======
|
||||
|
||||
@@ -1014,8 +1014,6 @@ const char* cmCMakePresetsGraph::ResultToString(ReadFileResult result)
|
||||
"support.";
|
||||
case ReadFileResult::CYCLIC_INCLUDE:
|
||||
return "Cyclic include among preset files";
|
||||
case ReadFileResult::INCLUDE_OUTSIDE_PROJECT:
|
||||
return "File included from outside project directory";
|
||||
}
|
||||
|
||||
return "Unknown error";
|
||||
|
||||
@@ -44,7 +44,6 @@ public:
|
||||
CONDITION_UNSUPPORTED,
|
||||
TOOLCHAIN_FILE_UNSUPPORTED,
|
||||
CYCLIC_INCLUDE,
|
||||
INCLUDE_OUTSIDE_PROJECT,
|
||||
};
|
||||
|
||||
enum class ArchToolsetStrategy
|
||||
|
||||
@@ -424,17 +424,6 @@ cmCMakePresetsGraph::ReadFileResult cmCMakePresetsGraph::ReadJSONFile(
|
||||
{
|
||||
ReadFileResult result;
|
||||
|
||||
if (rootType == RootType::Project) {
|
||||
auto normalizedFilename = cmSystemTools::CollapseFullPath(filename);
|
||||
|
||||
auto normalizedProjectDir =
|
||||
cmSystemTools::CollapseFullPath(this->SourceDir);
|
||||
if (!cmSystemTools::IsSubDirectory(normalizedFilename,
|
||||
normalizedProjectDir)) {
|
||||
return ReadFileResult::INCLUDE_OUTSIDE_PROJECT;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto const& f : this->Files) {
|
||||
if (cmSystemTools::SameFile(filename, f->Filename)) {
|
||||
file = f.get();
|
||||
@@ -444,21 +433,6 @@ cmCMakePresetsGraph::ReadFileResult cmCMakePresetsGraph::ReadJSONFile(
|
||||
return cmCMakePresetsGraph::ReadFileResult::CYCLIC_INCLUDE;
|
||||
}
|
||||
|
||||
// Check files included by this file again to make sure they're in the
|
||||
// project directory.
|
||||
if (rootType == RootType::Project) {
|
||||
for (auto* f2 : file->ReachableFiles) {
|
||||
if (!cmSystemTools::SameFile(filename, f2->Filename)) {
|
||||
File* file2;
|
||||
if ((result = this->ReadJSONFile(
|
||||
f2->Filename, rootType, ReadReason::Included,
|
||||
inProgressFiles, file2)) != ReadFileResult::READ_OK) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cmCMakePresetsGraph::ReadFileResult::READ_OK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
1
|
||||
@@ -1,2 +0,0 @@
|
||||
^CMake Error: Could not read presets from [^
|
||||
]*/Tests/RunCMake/CMakePresets/IncludeOutsideProject: File included from outside project directory$
|
||||
Reference in New Issue
Block a user