Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using pre-compiled headers with CMake

I have seen a few (old) posts on the 'net about hacking together some support for pre-compiled headers in CMake. They all seem a bit all-over the place and everyone has their own way of doing it. What is the best way of doing it currently?

like image 850
Glutinous Avatar asked Sep 29 '08 13:09

Glutinous


People also ask

Do you include header files in CMake?

With CMake, adding header include directories to your C++ project is as easy as using your head in football! Heading those C++ include directories is easy with CMake. As you are probably aware, you can include other source files in C++ with the #include pre-processor directive.

How do you Precompile headers?

The compiler options for precompiled headers are /Y . In the project property pages, the options are located under Configuration Properties > C/C++ > Precompiled Headers. You can choose to not use precompiled headers, and you can specify the header file name and the name and path of the output file.

What is Stdafx H?

h (named stdafx. h before Visual Studio 2017) is a file generated by the Microsoft Visual Studio IDE wizard, that describes both standard system and project specific include files that are used frequently but hardly ever change. The afx in stdafx. h stands for application framework extensions.


1 Answers

There is a third party CMake module named 'Cotire' which automates the use of precompiled headers for CMake based build systems and also supports unity builds.

like image 166
sakra Avatar answered Oct 22 '22 22:10

sakra