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.
stage/master/nightly/2023/02/07
Alexander Neundorf 2023-02-02 00:05:00 +01:00 committed by Brad King
parent 8a7aa2642b
commit 9a7612d2d0
4 changed files with 49 additions and 6 deletions

View File

@ -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

View File

@ -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.

View File

@ -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")

View File

@ -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;
}
s = cmStrCat(lg.GetSourceDirectory(), "/.svn");
if (cmSystemTools::FileExists(s)) {
return "\"svn\": 1 ";
std::string s;
// 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(), '/');