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 | |
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
-rw-r--r-- | Help/command/set_property.rst | 2 | ||||
-rw-r--r-- | Help/manual/cmake-variables.7.rst | 2 | ||||
-rw-r--r-- | Help/variable/CMAKE_KATE_FILES_MODE.rst | 20 | ||||
-rw-r--r-- | Help/variable/CMAKE_KATE_MAKE_ARGUMENTS.rst | 11 | ||||
-rw-r--r-- | Modules/CMakeFindKate.cmake | 8 | ||||
-rw-r--r-- | Source/cmExtraKateGenerator.cxx | 58 |
6 files changed, 90 insertions, 11 deletions
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 diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 23d8256..8564e7c 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -226,6 +226,8 @@ 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 /variable/CMAKE_LINK_LIBRARIES_ONLY_TARGETS diff --git a/Help/variable/CMAKE_KATE_FILES_MODE.rst b/Help/variable/CMAKE_KATE_FILES_MODE.rst new file mode 100644 index 0000000..195c15d --- /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``, ``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``, ``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/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..521bc5c 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,9 @@ 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<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..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; |