소스 검색

FindPackageMessage: Eliminate new lines using REGEX REPLACE

Re-fix problem exposed by recent commit to FindPythonInterp.
If the find "details" has new lines in it, then replace them
with the empty string so that the string may be saved as a
cache entry that can be re-read next time CMake runs.

Use REGEX REPLACE, and replace with an empty string, eliminating
the problem characters, so that we may easily extend this to
include additional problem characters in the future if necessary.
David Cole 14 년 전
부모
커밋
cd81da30f7
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      Modules/FindPackageMessage.cmake

+ 1 - 1
Modules/FindPackageMessage.cmake

@@ -34,7 +34,7 @@
 FUNCTION(FIND_PACKAGE_MESSAGE pkg msg details)
   # Avoid printing a message repeatedly for the same find result.
   IF(NOT ${pkg}_FIND_QUIETLY)
-    STRING(REPLACE "\n" "\\n" details "${details}")
+    STRING(REGEX REPLACE "[\n]" "" details "${details}")
     SET(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg})
     IF(NOT "${details}" STREQUAL "${${DETAILS_VAR}}")
       # The message has not yet been printed.