From 8a7aa2642bcc63b0434b1e5a212931cd96d27e31 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Wed, 1 Feb 2023 23:16:42 +0100 Subject: Help: add documentation for Kate-related variable --- Help/manual/cmake-variables.7.rst | 1 + Help/variable/CMAKE_KATE_MAKE_ARGUMENTS.rst | 11 +++++++++++ Modules/CMakeFindKate.cmake | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 Help/variable/CMAKE_KATE_MAKE_ARGUMENTS.rst diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 23d8256..5e09d62 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_MAKE_ARGUMENTS /variable/CMAKE_LIBRARY_PATH /variable/CMAKE_LINK_DIRECTORIES_BEFORE /variable/CMAKE_LINK_LIBRARIES_ONLY_TARGETS diff --git a/Help/variable/CMAKE_KATE_MAKE_ARGUMENTS.rst b/Help/variable/CMAKE_KATE_MAKE_ARGUMENTS.rst new file mode 100644 index 0000000..c830332 --- /dev/null +++ b/Help/variable/CMAKE_KATE_MAKE_ARGUMENTS.rst @@ -0,0 +1,11 @@ +CMAKE_KATE_MAKE_ARGUMENTS +------------------------- + +.. versionadded:: 3.0 + +This cache variable is used by the Kate project generator. See +:manual:`cmake-generators(7)`. + +This variable holds arguments which are used when Kate invokes the make +tool. By default it is initialized to hold flags to enable parallel builds +(using -j typically). diff --git a/Modules/CMakeFindKate.cmake b/Modules/CMakeFindKate.cmake index 9aaf6e5..23fbe38 100644 --- a/Modules/CMakeFindKate.cmake +++ b/Modules/CMakeFindKate.cmake @@ -3,7 +3,7 @@ # This file is included in CMakeSystemSpecificInformation.cmake if -# the Eclipse CDT4 extra generator has been selected. +# the Kate extra generator has been selected. # Try to find out how many CPUs we have and set the -j argument for make accordingly @@ -17,5 +17,5 @@ if("${_CMAKE_KATE_PROCESSOR_COUNT}" GREATER 1 AND CMAKE_HOST_UNIX AND "${CMA set(_CMAKE_KATE_INITIAL_MAKE_ARGS "-j${_CMAKE_KATE_PROCESSOR_COUNT}") endif() -# This variable is used by the Eclipse generator and appended to the make invocation commands. +# 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 to get parallel builds") -- cgit v0.12 From 9a7612d2d0889fc097d091e633e12914183ae23d Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Thu, 2 Feb 2023 00:05:00 +0100 Subject: 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. --- Help/manual/cmake-variables.7.rst | 1 + Help/variable/CMAKE_KATE_FILES_MODE.rst | 20 ++++++++++++++++++++ Modules/CMakeFindKate.cmake | 4 ++++ Source/cmExtraKateGenerator.cxx | 30 ++++++++++++++++++++++++------ 4 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 Help/variable/CMAKE_KATE_FILES_MODE.rst 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 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(), '/'); -- cgit v0.12 From 4c32623f5fcf66f4ef8dc2fb10a1ea15aeb063a6 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Thu, 2 Feb 2023 00:07:11 +0100 Subject: Help: fix typo in docs for set_property() --- Help/command/set_property.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Help/command/set_property.rst b/Help/command/set_property.rst index d446a2d..ca19e0c 100644 --- a/Help/command/set_property.rst +++ b/Help/command/set_property.rst @@ -90,7 +90,7 @@ It must be one of the following: for tests created by the :command:`add_test(NAME)` signature. ``CACHE`` - Scope must name zero or more cache existing entries. + Scope must name zero or more existing cache entries. The required ``PROPERTY`` option is immediately followed by the name of the property to set. Remaining arguments are used to compose the -- cgit v0.12 From 96389b4cd3dfa2632619fee5e1a16ca872f55973 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Thu, 2 Feb 2023 22:23:50 +0100 Subject: Kate: add support for hg and fossil Both VCS are supported by kate nowadays. --- Help/variable/CMAKE_KATE_FILES_MODE.rst | 10 +++++----- Source/cmExtraKateGenerator.cxx | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Help/variable/CMAKE_KATE_FILES_MODE.rst b/Help/variable/CMAKE_KATE_FILES_MODE.rst index e568e00..195c15d 100644 --- a/Help/variable/CMAKE_KATE_FILES_MODE.rst +++ b/Help/variable/CMAKE_KATE_FILES_MODE.rst @@ -7,14 +7,14 @@ 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``. +Possible values are ``AUTO``, ``SVN``, ``GIT``, ``HG``, ``FOSSIL`` 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 set to ``SVN``, ``GIT``, ``HG`` or ``FOSSIL``, CMake will set +the generated project accordingly to Subversion, git, Mercurial +or Fossil, and Kate will then use the respective command line tool 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/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index 5418fd3..5be8f26 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -225,6 +225,8 @@ std::string cmExtraKateGenerator::GenerateFilesString( 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; @@ -232,6 +234,12 @@ std::string cmExtraKateGenerator::GenerateFilesString( if (mode == "GIT") { return gitString; } + if (mode == "HG") { + return hgString; + } + if (mode == "FOSSIL") { + return fossilString; + } std::string s; @@ -246,6 +254,14 @@ std::string cmExtraKateGenerator::GenerateFilesString( if (cmSystemTools::FileExists(s)) { return svnString; } + s = cmStrCat(lg.GetSourceDirectory(), "/.hg"); + if (cmSystemTools::FileExists(s)) { + return hgString; + } + s = cmStrCat(lg.GetSourceDirectory(), "/.fslckout"); + if (cmSystemTools::FileExists(s)) { + return fossilString; + } } s = cmStrCat(lg.GetSourceDirectory(), '/'); -- cgit v0.12 From e7f7bff4f54f72bed6ca0dfac8a9989e8a44223c Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Thu, 2 Feb 2023 22:44:52 +0100 Subject: Kate: improve the way the VCS-specific files are searched Before, CMake only checked for the .svn etc. directory only in ${CMAKE_SOURCE_DIR}, now it also goes the directories up to check whether those VCS directories exist in one of the parent directories. --- Source/cmExtraKateGenerator.cxx | 46 ++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index 5be8f26..0d0b513 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -8,6 +8,7 @@ #include #include +#include "cmCMakePath.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" @@ -241,31 +242,38 @@ std::string cmExtraKateGenerator::GenerateFilesString( return fossilString; } - 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; - } + 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 = cmStrCat(lg.GetSourceDirectory(), "/.svn"); - if (cmSystemTools::FileExists(s)) { - return svnString; - } - s = cmStrCat(lg.GetSourceDirectory(), "/.hg"); - if (cmSystemTools::FileExists(s)) { - return hgString; - } - s = cmStrCat(lg.GetSourceDirectory(), "/.fslckout"); - if (cmSystemTools::FileExists(s)) { - return fossilString; + s = startDir.String() + "/.svn"; + if (cmSystemTools::FileExists(s)) { + return svnString; + } + + 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(); } } - s = cmStrCat(lg.GetSourceDirectory(), '/'); - std::set files; std::string tmp; const auto& lgs = this->GlobalGenerator->GetLocalGenerators(); -- cgit v0.12