mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
Reuse the logic from commit 637a0f7ed4 (cmCacheManager: Prevent
corruption from multiline help strings, 2025-02-04, v4.0.0-rc1~52^2)
for the warning message placed in the cache when a cache variable's
value contains one or more newline characters.
While we're at it, remove a superfluous early-exit in the help strings
method.
Fixes: #27807
Suggested-By: Yauheni Khnykin <yauheni.khnykin@here.com>
21 lines
890 B
CMake
21 lines
890 B
CMake
set(CACHE_EXPECTED_FILE "${RunCMake_TEST_SOURCE_DIR}/${case}-CMakeCacheRegex.txt")
|
|
set(CACHE_ACTUAL_FILE "${RunCMake_TEST_BINARY_DIR}/CMakeCache.txt")
|
|
|
|
if(NOT EXISTS ${CACHE_EXPECTED_FILE})
|
|
message(FATAL_ERROR "Could not find ${RunCMake_TEST_SOURCE_DIR}/${case}-CMakeCacheRegex.txt")
|
|
endif()
|
|
|
|
file(READ ${CACHE_EXPECTED_FILE} CACHE_EXPECTED)
|
|
string(REGEX REPLACE "\r\n" "\n" CACHE_EXPECTED "${CACHE_EXPECTED}")
|
|
string(REGEX REPLACE "\n+$" "" CACHE_EXPECTED "${CACHE_EXPECTED}")
|
|
file(READ ${CACHE_ACTUAL_FILE} CACHE_ACTUAL)
|
|
string(REGEX REPLACE "\r\n" "\n" CACHE_ACTUAL "${CACHE_ACTUAL}")
|
|
string(REGEX REPLACE "\n+$" "" CACHE_ACTUAL "${CACHE_ACTUAL}")
|
|
|
|
if(NOT "${CACHE_ACTUAL}" MATCHES "${CACHE_EXPECTED}")
|
|
set(RunCMake_TEST_FAILED "${CACHE_ACTUAL_FILE} does not match ${CACHE_EXPECTED_FILE}:
|
|
|
|
CMakeCache.txt contents = [\n${CACHE_ACTUAL}\n]
|
|
Expected = [\n${CACHE_EXPECTED}\n]")
|
|
endif()
|