From e61a59d8aacc737bfefe9890f7fb1cd0fcb854e3 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Wed, 9 Oct 2024 18:20:40 +0200 Subject: [PATCH] CMake: Fix semicolon handling Change-Id: I63fb5eeb644b955e54ba9047a056169e47bb12f9 Reviewed-by: Eike Ziller --- cmake/QtCreatorAPI.cmake | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/cmake/QtCreatorAPI.cmake b/cmake/QtCreatorAPI.cmake index 14e4b9d82b9..e05a48563bc 100644 --- a/cmake/QtCreatorAPI.cmake +++ b/cmake/QtCreatorAPI.cmake @@ -334,11 +334,18 @@ endfunction(add_qtc_library) function(markdown_to_json resultVarName filepath) file(STRINGS ${filepath} markdown) - list(TRANSFORM markdown REPLACE "\\\\" "\\\\\\\\") # Replace \ with \\ - list(TRANSFORM markdown REPLACE "\\\"" "\\\\\"") # Replace " with \" - list(TRANSFORM markdown PREPEND " \"" ) - list(TRANSFORM markdown APPEND "\"") - list(JOIN markdown ",\n" result) + set(result "") + foreach(line IN LISTS markdown) + string(REPLACE "\\" "\\\\" line "${line}") # Replace \ with \\ + string(REPLACE "\"" "\\\"" line "${line}") # Replace " with \" + string(PREPEND line " \"") + string(APPEND line "\"") + # We have to escape ; because list(APPEND ...) will split the string at ; + # list(JOIN ...) will replace the \; with ; again + string(REPLACE ";" "\\;" line "${line}") + list(APPEND result "${line}") + endforeach() + list(JOIN result ",\n" result) set(result "[\n${result}\n ]") set("${resultVarName}" ${result} PARENT_SCOPE) endfunction()