diff options
author | Brad King <brad.king@kitware.com> | 2022-01-20 16:55:22 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-01-20 16:55:35 (GMT) |
commit | a47b4387b40047f9b9e0cf5f7dbe7c1fe056355e (patch) | |
tree | 0b350e2c1dc8e0dd16aa9cdfad67c628ba421368 | |
parent | 410dd6cf611f31ebca74e1db4dc439e6fcaf34b4 (diff) | |
parent | 0c2d234bc9be8fbdad5b14d3d5e66026a5d6e2fc (diff) | |
download | CMake-a47b4387b40047f9b9e0cf5f7dbe7c1fe056355e.zip CMake-a47b4387b40047f9b9e0cf5f7dbe7c1fe056355e.tar.gz CMake-a47b4387b40047f9b9e0cf5f7dbe7c1fe056355e.tar.bz2 |
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
-rw-r--r-- | Help/manual/cmake-presets.7.rst | 7 | ||||
-rw-r--r-- | Source/cmCMakePresetsGraph.cxx | 2 | ||||
-rw-r--r-- | Source/cmCMakePresetsGraph.h | 1 | ||||
-rw-r--r-- | Source/cmCMakePresetsGraphReadJSON.cxx | 26 | ||||
-rw-r--r-- | Tests/RunCMake/CMakePresets/IncludeOutsideProject-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CMakePresets/IncludeOutsideProject-stderr.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/CMakePresets/IncludeOutsideProject.cmake | 0 |
7 files changed, 3 insertions, 36 deletions
diff --git a/Help/manual/cmake-presets.7.rst b/Help/manual/cmake-presets.7.rst index 474e1aa..e702d97 100644 --- a/Help/manual/cmake-presets.7.rst +++ b/Help/manual/cmake-presets.7.rst @@ -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 ====== diff --git a/Source/cmCMakePresetsGraph.cxx b/Source/cmCMakePresetsGraph.cxx index 58dca36..238aa68 100644 --- a/Source/cmCMakePresetsGraph.cxx +++ b/Source/cmCMakePresetsGraph.cxx @@ -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"; diff --git a/Source/cmCMakePresetsGraph.h b/Source/cmCMakePresetsGraph.h index 02c506f..8581809 100644 --- a/Source/cmCMakePresetsGraph.h +++ b/Source/cmCMakePresetsGraph.h @@ -44,7 +44,6 @@ public: CONDITION_UNSUPPORTED, TOOLCHAIN_FILE_UNSUPPORTED, CYCLIC_INCLUDE, - INCLUDE_OUTSIDE_PROJECT, }; enum class ArchToolsetStrategy diff --git a/Source/cmCMakePresetsGraphReadJSON.cxx b/Source/cmCMakePresetsGraphReadJSON.cxx index ca34124..85cf5be 100644 --- a/Source/cmCMakePresetsGraphReadJSON.cxx +++ b/Source/cmCMakePresetsGraphReadJSON.cxx @@ -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; } } diff --git a/Tests/RunCMake/CMakePresets/IncludeOutsideProject-result.txt b/Tests/RunCMake/CMakePresets/IncludeOutsideProject-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/CMakePresets/IncludeOutsideProject-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/CMakePresets/IncludeOutsideProject-stderr.txt b/Tests/RunCMake/CMakePresets/IncludeOutsideProject-stderr.txt deleted file mode 100644 index 2aa3f59..0000000 --- a/Tests/RunCMake/CMakePresets/IncludeOutsideProject-stderr.txt +++ /dev/null @@ -1,2 +0,0 @@ -^CMake Error: Could not read presets from [^ -]*/Tests/RunCMake/CMakePresets/IncludeOutsideProject: File included from outside project directory$ diff --git a/Tests/RunCMake/CMakePresets/IncludeOutsideProject.cmake b/Tests/RunCMake/CMakePresets/IncludeOutsideProject.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/IncludeOutsideProject.cmake |