diff options
author | Brad King <brad.king@kitware.com> | 2023-02-07 14:47:58 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-02-07 14:48:23 (GMT) |
commit | 9492ca9a3f21d35ca159e8da6a76abaa71a8d43c (patch) | |
tree | f4e1576d443b51b0c95571df6a0e6d77a6d7bc5b /Source | |
parent | 20b6356cab9d2c3b29d9a9235d6cda02d67d25a6 (diff) | |
parent | e7f7bff4f54f72bed6ca0dfac8a9989e8a44223c (diff) | |
download | CMake-9492ca9a3f21d35ca159e8da6a76abaa71a8d43c.zip CMake-9492ca9a3f21d35ca159e8da6a76abaa71a8d43c.tar.gz CMake-9492ca9a3f21d35ca159e8da6a76abaa71a8d43c.tar.bz2 |
Merge topic 'KateImprovements'
e7f7bff4f5 Kate: improve the way the VCS-specific files are searched
96389b4cd3 Kate: add support for hg and fossil
4c32623f5f Help: fix typo in docs for set_property()
9a7612d2d0 Kate: make it possible to force a mode for the "files" entry
8a7aa2642b Help: add documentation for Kate-related variable
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8154
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmExtraKateGenerator.cxx | 58 |
1 files changed, 50 insertions, 8 deletions
diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index eec43c4..0d0b513 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -8,6 +8,7 @@ #include <set> #include <vector> +#include "cmCMakePath.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" @@ -220,17 +221,58 @@ void cmExtraKateGenerator::CreateDummyKateProjectFile( std::string cmExtraKateGenerator::GenerateFilesString( const cmLocalGenerator& lg) const { - std::string s = cmStrCat(lg.GetSourceDirectory(), "/.git"); - if (cmSystemTools::FileExists(s)) { - return "\"git\": 1 "; + const cmMakefile* mf = lg.GetMakefile(); + std::string mode = + cmSystemTools::UpperCase(mf->GetSafeDefinition("CMAKE_KATE_FILES_MODE")); + static const std::string gitString = "\"git\": 1 "; + static const std::string svnString = "\"svn\": 1 "; + static const std::string hgString = "\"hg\": 1 "; + static const std::string fossilString = "\"fossil\": 1 "; + + if (mode == "SVN") { + return svnString; } - - s = cmStrCat(lg.GetSourceDirectory(), "/.svn"); - if (cmSystemTools::FileExists(s)) { - return "\"svn\": 1 "; + if (mode == "GIT") { + return gitString; + } + if (mode == "HG") { + return hgString; } + if (mode == "FOSSIL") { + return fossilString; + } + + // check for the VCS files except when "forced" to "FILES" mode: + if (mode != "LIST") { + cmCMakePath startDir(lg.GetSourceDirectory(), cmCMakePath::auto_format); + // move the directories up to the root directory to see whether we are in + // a subdir of a svn, git, hg or fossil checkout + for (;;) { + std::string s = startDir.String() + "/.git"; + if (cmSystemTools::FileExists(s)) { + return gitString; + } + + s = startDir.String() + "/.svn"; + if (cmSystemTools::FileExists(s)) { + return svnString; + } - s = cmStrCat(lg.GetSourceDirectory(), '/'); + s = startDir.String() + "/.hg"; + if (cmSystemTools::FileExists(s)) { + return hgString; + } + s = startDir.String() + "/.fslckout"; + if (cmSystemTools::FileExists(s)) { + return fossilString; + } + + if (!startDir.HasRelativePath()) { // have we reached the root dir ? + break; + } + startDir = startDir.GetParentPath(); + } + } std::set<std::string> files; std::string tmp; |