summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2023-02-01 23:05:00 (GMT)
committerBrad King <brad.king@kitware.com>2023-02-06 15:21:19 (GMT)
commit9a7612d2d0889fc097d091e633e12914183ae23d (patch)
tree79d269ab4d53c8f8e5e8af0200324c3c835ee4a7
parent8a7aa2642bcc63b0434b1e5a212931cd96d27e31 (diff)
downloadCMake-9a7612d2d0889fc097d091e633e12914183ae23d.zip
CMake-9a7612d2d0889fc097d091e633e12914183ae23d.tar.gz
CMake-9a7612d2d0889fc097d091e633e12914183ae23d.tar.bz2
Kate: make it possible to force a mode for the "files" entry
By default, kate will try to autodetect whether the project is a svn or git checkout or not. In case this does not give a satisfying result, the user can now set CMAKE_KATE_FILES_MODE to the mode he wants.
-rw-r--r--Help/manual/cmake-variables.7.rst1
-rw-r--r--Help/variable/CMAKE_KATE_FILES_MODE.rst20
-rw-r--r--Modules/CMakeFindKate.cmake4
-rw-r--r--Source/cmExtraKateGenerator.cxx30
4 files changed, 49 insertions, 6 deletions
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 5e09d62..8564e7c 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -226,6 +226,7 @@ Variables that Change Behavior
/variable/CMAKE_INSTALL_MESSAGE
/variable/CMAKE_INSTALL_PREFIX
/variable/CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT
+ /variable/CMAKE_KATE_FILES_MODE
/variable/CMAKE_KATE_MAKE_ARGUMENTS
/variable/CMAKE_LIBRARY_PATH
/variable/CMAKE_LINK_DIRECTORIES_BEFORE
diff --git a/Help/variable/CMAKE_KATE_FILES_MODE.rst b/Help/variable/CMAKE_KATE_FILES_MODE.rst
new file mode 100644
index 0000000..e568e00
--- /dev/null
+++ b/Help/variable/CMAKE_KATE_FILES_MODE.rst
@@ -0,0 +1,20 @@
+CMAKE_KATE_FILES_MODE
+---------------------
+
+.. versionadded:: 3.27
+
+This cache variable is used by the Kate project generator and controls
+to what mode the ``files`` entry in the project file will be set. See
+:manual:`cmake-generators(7)`.
+
+Possible values are ``AUTO``, ``SVN``, ``GIT`` and ``LIST``.
+
+When set to ``LIST``, CMake will put the list of source files known to CMake
+in the project file.
+When set to ``SVN``, CMake will put ``svn`` into the project file so that Kate
+will use svn to retrieve the list of files in the project.
+When set to ``GIT``, CMake will put ``git`` into the project file so that Kate
+will use git to retrieve the list of files in the project.
+When unset or set to ``AUTO``, CMake will try to detect whether the
+source directory is part of a git or svn checkout or not, and put the
+respective entry into the project file.
diff --git a/Modules/CMakeFindKate.cmake b/Modules/CMakeFindKate.cmake
index 23fbe38..521bc5c 100644
--- a/Modules/CMakeFindKate.cmake
+++ b/Modules/CMakeFindKate.cmake
@@ -19,3 +19,7 @@ endif()
# This variable is used by the Kate generator and appended to the make invocation commands.
set(CMAKE_KATE_MAKE_ARGUMENTS "${_CMAKE_KATE_INITIAL_MAKE_ARGS}" CACHE STRING "Additional command line arguments when Kate invokes make. Enter e.g. -j<some_number> to get parallel builds")
+
+
+set(CMAKE_KATE_FILES_MODE "AUTO" CACHE STRING "Option to override the version control detection and force a mode for the Kate project.")
+set_property(CACHE CMAKE_KATE_FILES_MODE PROPERTY STRINGS "AUTO;SVN;GIT;LIST")
diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx
index eec43c4..5418fd3 100644
--- a/Source/cmExtraKateGenerator.cxx
+++ b/Source/cmExtraKateGenerator.cxx
@@ -220,14 +220,32 @@ 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 ";
+
+ if (mode == "SVN") {
+ return svnString;
}
+ if (mode == "GIT") {
+ return gitString;
+ }
+
+ std::string s;
- s = cmStrCat(lg.GetSourceDirectory(), "/.svn");
- if (cmSystemTools::FileExists(s)) {
- return "\"svn\": 1 ";
+ // check for the VCS files except when "forced" to "FILES" mode:
+ if (mode != "LIST") {
+ s = cmStrCat(lg.GetSourceDirectory(), "/.git");
+ if (cmSystemTools::FileExists(s)) {
+ return gitString;
+ }
+
+ s = cmStrCat(lg.GetSourceDirectory(), "/.svn");
+ if (cmSystemTools::FileExists(s)) {
+ return svnString;
+ }
}
s = cmStrCat(lg.GetSourceDirectory(), '/');