Important: Please read the Qt Code of Conduct -

How to use precompiled headers in CMake project in QtCreator?

  • Hello
    I trying to use a precompiled header in CMake project. Cotire module provides this functionality. But QtCreator code highlight not working. It seems that QtCreator code model doesn't parse a precompiled header.
    Here is a project example:


    cmake_minimum_required(VERSION 2.8)
    add_executable(${PROJECT_NAME} "main.cpp")
    set_target_properties(${PROJECT_NAME} PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "Stable.h")


    int main()
      std::vector<int> vec;
      std::cout << vec.size() << std::endl;
      return 0;


    #include <iostream>
    #include <vector>

    Both Clang and built-in code model have this problem. But build performs with success.
    In dialog Tools -> C++ -> Inspect C++ Code Model... a Precompiled headers key is set to <None>.

    May be there is a different way to specify a precompiled header in CMake project that QtCreator can resolve?

    QtCreator 4.8.2

  • I ran into the same problem and this problem is very very annoying during daily work.

    I filed a bug report for that issue.