CMakePCHCompiler
CMakePCHCompiler copied to clipboard
PCH breaks clang code model in Qt Creator.
It's not CMakePCHCompiler problem. It's common. Qt Creator uses clang to have good syntax higlighting. This option is optional but by default it's enabled. This means Qt Creator compiles each file with clang with compile options which set by CMake project + plus something set in Qt Creator settings. For example. I use such command to compile my file
g++ -g -O2 -DFOO=bar -Wall -include CMakeFiles/pch.dir/pch.h -o main.cpp.o -c main.cpp
Qt Creator based on this command use such command to parse main.cpp
clang++ -g -O2 -DFOO=bar -Wall -include CMakeFiles/pch.dir/pch.h -pedantic -o main.cpp.o -c main.cpp
This command fails due gcc pch format is not compatible with clang pch format. So Qt Creator can't parse main.cpp and colorize source code. I opened QTCREATORBUG-22427. Also I found a workaround for this. Need to put pch.h
near with pch.h.gch
and compile sources with -Wno-invalid-pch