Issue
I want to have a nice clean 80 column CMakeLists.txt. I tried to use line break in one of the lines but then I got a warning about it (3rd line below):
else()
target_compile_definitions(${PROJECT_NAME} PUBLIC
QT_MESSAGE_PATTERN="%{time dd:MM:yyyy-h:mm:ss:zzz} %{type} \
%{pid}\t%{message}"
)
endif()
And here is the warning:
CMake Warning (dev) at CMakeLists.txt:78:
Syntax Warning in cmake code at column 28
Argument not separated from preceding token by whitespace.
How can I fix this? or do it properly?
Solution
Your issue is with the quoting not with the line break. The error message points at line 78, column 28 (there's a quote next to this position). You need to enclose the entire argument in quotes and escape the inner quotes , so your target_compile_definitions
argument would become:
"QT_MESSAGE_PATTERN=\"%{time dd:MM:yyyy-h:mm:ss:zzz} %{type} \
%{pid}\t%{message}\""
See here for further explanations.
A small CMake test project looks like this:
cmake_minimum_required(VERSION 3.0)
project(quoteTest)
add_executable(quoteTest main.cpp)
target_compile_definitions(${PROJECT_NAME} PUBLIC
"QT_MESSAGE_PATTERN=\"%{time dd:MM:yyyy-h:mm:ss:zzz} %{type} \
%{pid}\t%{message}\""
)
Answered By - vre Answer Checked By - Pedro (WPSolving Volunteer)