我在尝试打印带有新行的字符串时遇到了问题CMakeLists.txt
。
预期输出:
{file}:{line}:{column}
Message: {message}
Check: CWE-{cwe}
Type: {severity} -> {id}
Line: {line}:{column}
Stack: {callstack}
{code}
如果我尝试放置新的换行符 ( \n
),则会返回错误:
set(CPPCHECK_TEMPLATE "")
string(APPEND CPPCHECK_TEMPLATE "{file}:{line}:{column}\n")
string(APPEND CPPCHECK_TEMPLATE " Message: {message}\n")
string(APPEND CPPCHECK_TEMPLATE " Check: CWE-{cwe}\n")
string(APPEND CPPCHECK_TEMPLATE " Type: {severity} -> {id}\n")
string(APPEND CPPCHECK_TEMPLATE " Line: {line}:{column}\n")
string(APPEND CPPCHECK_TEMPLATE " Stack: {callstack}\n")
string(APPEND CPPCHECK_TEMPLATE "{code}\n")
执行:
add_custom_command(
COMMENT "Scanning: CPP Check\n"
TARGET ${PROJECT_NAME}
PRE_BUILD
COMMAND cppcheck
"--template=${CPPCHECK_TEMPLATE}"
VERBATIM
)
错误:
/home/wolf/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/211.7142.21/bin/cmake/linux/bin/cmake --build /home/wolf/workspace/projects/bose-connect-app-linux/src/cmake-build-debug --target clean -- -j 6
CMakeFiles/bose-connect-app-linux.dir/build.make:157: *** target pattern contains no '%'. Stop.
make[1]: *** [CMakeFiles/Makefile2:113: CMakeFiles/bose-connect-app-linux.dir/clean] Error 2
make: *** [Makefile:109: clean] Error 2