2

In my project there are some headers which almost using in all files. So, to increase the speed of building I've decided to use Pre-compiled headers. I'm using CMake 3.15 and clang++. In CMake 3.16 we can use target_precompile_headers(). But in 3.15 it is not available.

I will try to explain a sample here. I have common headers such as engine.h, wheel.h, door.h. These files are stored at my_proj/includes/ directory. And these headers are including in all my subprojects.

I would like to know how to make and use them as pre-compiled headers in cmake 3.15 from scartch.

Aravind
  • 41
  • 5
  • Why not just update to newer cmake? | What have you tried? Just write a `add_custom_command` then create a `add_library(preheaders INTERFACE)` and add include path to it with precompiled headers and link with it. There is no CMake support - so you got to do it manually. – KamilCuk Sep 02 '21 at 07:58
  • I have some restrictions in updating the cmake as there is a team using cmake 3.15. Thanks for your suggestion. But can you please explain in some more detail how I can acomplish this using Cmake 3.15 manually. – Aravind Sep 02 '21 at 09:02
  • https://stackoverflow.com/a/39387590/9072753 https://github.com/larsch/cmake-precompiled-header/blob/master/PrecompiledHeader.cmake#L168 https://www.openmodelica.org/svn/OpenModelica/trunk/SimulationRuntime/cpp/PrecompiledHeader.cmake – KamilCuk Sep 02 '21 at 09:10

0 Answers0