Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt5, CMake, AUTOMOC and precompiled headers

How to specify a precompiled header to the output of CMake (2.8.12.1) AUTOMOC ?

So far, in the CMakeLists.txt I've tried these two separately:

 set(AUTOMOC_MOC_OPTIONS "-bstdafx.h")
 set(AUTOMOC_MOC_OPTIONS "-fstdafx.h")

The generated AUTOMOC output when building the project (project_automoc.cpp) only contains the moc_xxx.cpp files:

/* This file is autogenerated, do not edit*/
/// <- stdafx.h should be here ?!?!
#include "moc_widget_fps.cpp"
#include "moc_widget_sysevents.cpp"
like image 290
Pencheff Avatar asked Jan 30 '14 18:01

Pencheff


1 Answers

The correct variable to set is called CMAKE_AUTOMOC_MOC_OPTIONS. It is used to initialize the AUTOMOC_MOC_OPTIONS property of a target, i.e.:

set (CMAKE_AUTOMOC_MOC_OPTIONS "-bstdafx.h" "-fstdafx.h")

Also note that this will only make the Qt MOC compiler add the given includes to each generated moc_xxx.cpp file. The overall project_automoc.cpp will not be affected.

like image 113
sakra Avatar answered Sep 17 '22 15:09

sakra