Avoid unexpected line breaks in version_string.inc

The Android NDK 16b has a bug that sets the ANDROID_NDK_REVISION
variable incorrectly, generating an unexpected line break in the
middle of the string. This breaks the build as the generated
version_string.inc presents an invalid C string.

Remove leading and trailing line breaks, warns for line breaks in the
middle of 'msg' and escape them before appending to
OPENCV_BUILD_INFO_STR.
parent 98e2bb87
...@@ -784,6 +784,11 @@ function(ocv_output_status msg) ...@@ -784,6 +784,11 @@ function(ocv_output_status msg)
message(STATUS "${msg}") message(STATUS "${msg}")
string(REPLACE "\\" "\\\\" msg "${msg}") string(REPLACE "\\" "\\\\" msg "${msg}")
string(REPLACE "\"" "\\\"" msg "${msg}") string(REPLACE "\"" "\\\"" msg "${msg}")
string(REGEX REPLACE "^\n+|\n+$" "" msg "${msg}")
if(msg MATCHES "\n")
message(WARNING "String to be inserted to version_string.inc has an unexpected line break: '${msg}'")
string(REPLACE "\n" "\\n" msg "${msg}")
endif()
set(OPENCV_BUILD_INFO_STR "${OPENCV_BUILD_INFO_STR}\"${msg}\\n\"\n" CACHE INTERNAL "") set(OPENCV_BUILD_INFO_STR "${OPENCV_BUILD_INFO_STR}\"${msg}\\n\"\n" CACHE INTERNAL "")
endfunction() endfunction()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment