Merge topic 'fix-spelling-typo-found-by-codespell-2.4'
7d4086d239 codespell: Fix one more typo found by version 2.4
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10246
diff --git a/Help/command/load_cache.rst b/Help/command/load_cache.rst
index 877c2bb..86d1e85 100644
--- a/Help/command/load_cache.rst
+++ b/Help/command/load_cache.rst
@@ -21,6 +21,8 @@
For each cache ``<entry>``, a local variable is created using the specified
``<prefix>`` followed by the entry name.
+ This signature can be also used in :option:`cmake -P` script mode.
+
The following signature of this command is strongly discouraged, but it is
provided for backward compatibility:
@@ -42,6 +44,18 @@
This option can be used to provide a list of internal cache entries to
include in addition to the non-internal cache entries.
+ This signature can be used only in CMake projects. Script mode is not
+ supported.
+
+.. note::
+
+ Instead of loading the outside project's cache file and manually accessing
+ variables, a more robust and convenient approach is to use the
+ :command:`export` command in the outside project, when available. This allows
+ the project to provide its targets, configuration, or features in a
+ structured and maintainable way, making integration simpler and less
+ error-prone.
+
Examples
^^^^^^^^
diff --git a/Help/manual/cmake-commands.7.rst b/Help/manual/cmake-commands.7.rst
index 26b41d8..6f1a947 100644
--- a/Help/manual/cmake-commands.7.rst
+++ b/Help/manual/cmake-commands.7.rst
@@ -51,6 +51,7 @@
/command/include
/command/include_guard
/command/list
+ /command/load_cache
/command/macro
/command/mark_as_advanced
/command/math
@@ -105,7 +106,6 @@
/command/install
/command/link_directories
/command/link_libraries
- /command/load_cache
/command/project
/command/remove_definitions
/command/set_source_files_properties
diff --git a/Modules/GoogleTest.cmake b/Modules/GoogleTest.cmake
index 17800b1..0c0b8a9 100644
--- a/Modules/GoogleTest.cmake
+++ b/Modules/GoogleTest.cmake
@@ -400,9 +400,9 @@
message(FATAL_ERROR "${arg_TARGET} does not define an existing CMake target")
endif()
if(NOT arg_WORKING_DIRECTORY)
- unset(workDir)
+ unset(maybe_WORKING_DIRECTORY)
else()
- set(workDir WORKING_DIRECTORY "${arg_WORKING_DIRECTORY}")
+ set(maybe_WORKING_DIRECTORY "WORKING_DIRECTORY \${arg_WORKING_DIRECTORY}")
endif()
if(NOT arg_SOURCES)
@@ -492,11 +492,11 @@
${arg_TEST_PREFIX}${orig_test_name}${arg_TEST_SUFFIX}
)
cmake_language(EVAL CODE "
- add_test(NAME ${ctest_test_name}
- ${workDir}
- COMMAND ${arg_TARGET}
+ add_test(NAME \${ctest_test_name}
+ ${maybe_WORKING_DIRECTORY}
+ COMMAND \${arg_TARGET}
--gtest_also_run_disabled_tests
- --gtest_filter=${gtest_test_name}
+ --gtest_filter=\${gtest_test_name}
${extra_args}
__CMP0178 [==[${cmp0178}]==]
)"
@@ -508,10 +508,10 @@
else()
set(ctest_test_name ${arg_TEST_PREFIX}${gtest_test_name}${arg_TEST_SUFFIX})
cmake_language(EVAL CODE "
- add_test(NAME ${ctest_test_name}
- ${workDir}
- COMMAND ${arg_TARGET}
- --gtest_filter=${gtest_test_name}
+ add_test(NAME \${ctest_test_name}
+ ${maybe_WORKING_DIRECTORY}
+ COMMAND \${arg_TARGET}
+ --gtest_filter=\${gtest_test_name}
${extra_args}
__CMP0178 [==[${cmp0178}]==]
)"
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index d398479..fa216e4 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 31)
-set(CMake_VERSION_PATCH 20250128)
+set(CMake_VERSION_PATCH 20250129)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/cmFileAPI.cxx b/Source/cmFileAPI.cxx
index ba2167b..1b2f365 100644
--- a/Source/cmFileAPI.cxx
+++ b/Source/cmFileAPI.cxx
@@ -200,7 +200,28 @@
}
// Compute the final name for the file.
- fileName = prefix + "-" + computeSuffix(tmpFile) + ".json";
+ std::string suffix = computeSuffix(tmpFile);
+ std::string suffixWithExtension = cmStrCat("-", suffix, ".json");
+ fileName = cmStrCat(prefix, suffixWithExtension);
+
+ // Truncate the file name length
+ // eCryptFS has a maximal file name length recommendation of 140
+ size_t const maxFileNameLength = 140;
+ size_t const fileNameLength = fileName.size();
+ if (fileNameLength > maxFileNameLength) {
+ size_t const newHashLength = 20;
+ size_t const newSuffixLength =
+ suffixWithExtension.size() - suffix.size() + newHashLength;
+ size_t const overLength =
+ fileNameLength - maxFileNameLength + newSuffixLength;
+ size_t const startPos = fileNameLength - overLength;
+ std::string const toBeRemoved = fileName.substr(startPos, overLength);
+ suffix = cmCryptoHash(cmCryptoHash::AlgoSHA256)
+ .HashString(toBeRemoved)
+ .substr(0, newHashLength);
+ suffixWithExtension = cmStrCat("-", suffix, ".json");
+ fileName.replace(startPos, overLength, suffixWithExtension);
+ }
// Create the destination.
std::string file = this->APIv1 + "/reply";
diff --git a/Source/kwsys/RegularExpression.cxx b/Source/kwsys/RegularExpression.cxx
index e6e16e5..cb7e0fb 100644
--- a/Source/kwsys/RegularExpression.cxx
+++ b/Source/kwsys/RegularExpression.cxx
@@ -861,7 +861,8 @@
// find -- Matches the regular expression to the given string.
// Returns true if found, and sets start and end indexes accordingly.
bool RegularExpression::find(char const* string,
- RegularExpressionMatch& rmatch) const
+ RegularExpressionMatch& rmatch,
+ std::string::size_type offset) const
{
char const* s;
@@ -882,7 +883,7 @@
// If there is a "must appear" string, look for it.
if (this->regmust) {
- s = string;
+ s = string + offset;
while ((s = strchr(s, this->regmust[0]))) {
if (strncmp(s, this->regmust, this->regmlen) == 0)
break; // Found it.
@@ -896,14 +897,13 @@
// Mark beginning of line for ^ .
regFind.regbol = string;
+ s = string + offset;
// Simplest case: anchored match need be tried only once.
if (this->reganch)
- return (
- regFind.regtry(string, rmatch.startp, rmatch.endp, this->program) != 0);
+ return (regFind.regtry(s, rmatch.startp, rmatch.endp, this->program) != 0);
// Messy cases: unanchored match.
- s = string;
if (this->regstart != '\0')
// We know what char it must start with.
while ((s = strchr(s, this->regstart))) {
diff --git a/Source/kwsys/RegularExpression.hxx.in b/Source/kwsys/RegularExpression.hxx.in
index b9eef35..184d6ac 100644
--- a/Source/kwsys/RegularExpression.hxx.in
+++ b/Source/kwsys/RegularExpression.hxx.in
@@ -121,6 +121,9 @@
*/
inline std::string::size_type RegularExpressionMatch::start(int n) const
{
+ if (!this->startp[n]) {
+ return std::string::npos;
+ }
return static_cast<std::string::size_type>(this->startp[n] -
this->searchstring);
}
@@ -131,6 +134,9 @@
*/
inline std::string::size_type RegularExpressionMatch::end(int n) const
{
+ if (!this->endp[n]) {
+ return std::string::npos;
+ }
return static_cast<std::string::size_type>(this->endp[n] -
this->searchstring);
}
@@ -338,19 +344,20 @@
* This method is thread safe when called with different
* RegularExpressionMatch instances.
*/
- bool find(char const*, RegularExpressionMatch&) const;
+ bool find(char const*, RegularExpressionMatch&,
+ std::string::size_type offset = 0) const;
/**
* Matches the regular expression to the given string.
* Returns true if found, and sets start and end indexes accordingly.
*/
- inline bool find(char const*);
+ inline bool find(char const*, std::string::size_type offset = 0);
/**
* Matches the regular expression to the given std string.
* Returns true if found, and sets start and end indexes accordingly.
*/
- inline bool find(std::string const&);
+ inline bool find(std::string const&, std::string::size_type offset = 0);
/**
* Match indices
@@ -474,18 +481,20 @@
* Matches the regular expression to the given std string.
* Returns true if found, and sets start and end indexes accordingly.
*/
-inline bool RegularExpression::find(char const* s)
+inline bool RegularExpression::find(char const* s,
+ std::string::size_type offset)
{
- return this->find(s, this->regmatch);
+ return this->find(s, this->regmatch, offset);
}
/**
* Matches the regular expression to the given std string.
* Returns true if found, and sets start and end indexes accordingly.
*/
-inline bool RegularExpression::find(std::string const& s)
+inline bool RegularExpression::find(std::string const& s,
+ std::string::size_type offset)
{
- return this->find(s.c_str());
+ return this->find(s.c_str(), offset);
}
/**
diff --git a/Tests/RunCMake/FileAPI/cmakeFiles-v1-check.py b/Tests/RunCMake/FileAPI/cmakeFiles-v1-check.py
index 9410c7e..54ca394 100644
--- a/Tests/RunCMake/FileAPI/cmakeFiles-v1-check.py
+++ b/Tests/RunCMake/FileAPI/cmakeFiles-v1-check.py
@@ -76,6 +76,12 @@
"isCMake": None,
},
{
+ "path": "^dir/very-long/CMakeLists\\.txt$",
+ "isGenerated": None,
+ "isExternal": None,
+ "isCMake": None,
+ },
+ {
"path": "^dir/dirtest\\.cmake$",
"isGenerated": None,
"isExternal": None,
diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py
index 36f9d33..b7b0090 100644
--- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py
+++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py
@@ -94,6 +94,8 @@
assert is_string(actual["jsonFile"])
filepath = os.path.join(reply_dir, actual["jsonFile"])
+ maximum_filename_length = 140
+ assert len(actual["jsonFile"]) <= maximum_filename_length
with open(filepath) as f:
d = json.load(f)
@@ -747,6 +749,7 @@
read_codemodel_json_data("directories/object.json"),
read_codemodel_json_data("directories/dir.json"),
read_codemodel_json_data("directories/dir_dir.json"),
+ read_codemodel_json_data("directories/dir_very-long.json"),
read_codemodel_json_data("directories/external.json"),
read_codemodel_json_data("directories/fileset.json"),
read_codemodel_json_data("directories/subdir.json"),
diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/dir.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/dir.json
index 2a3756e..dfa1e8b 100644
--- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/dir.json
+++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/dir.json
@@ -3,7 +3,8 @@
"build": "^dir$",
"parentSource": "^\\.$",
"childSources": [
- "^dir/dir$"
+ "^dir/dir$",
+ "^dir/very-long$"
],
"targetIds": null,
"projectName": "codemodel-v2",
diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/dir_very-long.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/dir_very-long.json
new file mode 100644
index 0000000..117f356
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/dir_very-long.json
@@ -0,0 +1,11 @@
+{
+ "source": "^dir/very-long",
+ "build": "^dir/very-long-directory-name-in-order-to-test-that-the-fileapi-codemodel-v2-directory-object-is-placed-in-a-json-file-on-disk-with-a-shortened-name$",
+ "parentSource": "^dir$",
+ "childSources": null,
+ "targetIds": null,
+ "projectName": "codemodel-v2",
+ "minimumCMakeVersion": "3.13",
+ "hasInstallRule": null,
+ "installers": []
+}
diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/codemodel-v2.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/codemodel-v2.json
index 8d2712d..9309407 100644
--- a/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/codemodel-v2.json
+++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/codemodel-v2.json
@@ -15,6 +15,7 @@
"^\\.$",
"^dir$",
"^dir/dir$",
+ "^dir/very-long$",
"^fileset$",
"^subdir$"
],
diff --git a/Tests/RunCMake/FileAPI/dir/CMakeLists.txt b/Tests/RunCMake/FileAPI/dir/CMakeLists.txt
index 780445d..70b2ba7 100644
--- a/Tests/RunCMake/FileAPI/dir/CMakeLists.txt
+++ b/Tests/RunCMake/FileAPI/dir/CMakeLists.txt
@@ -1 +1,2 @@
add_subdirectory(dir)
+add_subdirectory(very-long very-long-directory-name-in-order-to-test-that-the-fileapi-codemodel-v2-directory-object-is-placed-in-a-json-file-on-disk-with-a-shortened-name)
diff --git a/Tests/RunCMake/FileAPI/dir/very-long/CMakeLists.txt b/Tests/RunCMake/FileAPI/dir/very-long/CMakeLists.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/dir/very-long/CMakeLists.txt
diff --git a/Tests/RunCMake/GoogleTest/Launcher.cmake b/Tests/RunCMake/GoogleTest/Launcher.cmake
index 11ba87e..13ebd21 100644
--- a/Tests/RunCMake/GoogleTest/Launcher.cmake
+++ b/Tests/RunCMake/GoogleTest/Launcher.cmake
@@ -27,9 +27,11 @@
gtest_discover_tests(
launcher_test
EXTRA_ARGS a "" b
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
gtest_add_tests(
TARGET launcher_test
EXTRA_ARGS a "" b
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)