larsch / cmake-precompiled-header

Visual Studio and GCC precompiled header macro for CMake

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cmake-precompiled-header

Precompiled header setup for CMake. Supported CMake generators:

  • Visual Studio
  • NMake Makefiles
  • Unix Makefiles (GCC)
  • MinGW Makefiles
  • MSYS Makefiles
  • Ninja

Usage

Create a pchheader.{c,cpp} and pchheader.h and add then to the CMake target:

add_library(target ... pchheader.cpp pchheeader.h)

pchheader.h can include all the huge header files that are used everywhere in your project:

#include <string>
#include <iostream>
#include <list>
#include <map>

pchheader.{c,cpp} should just include the header file:

#include "pchheader.h"

In your main CMakeLists.txt, include the macro file:

include(PrecompiledHeader.cmake)

Then add this line, to set up precompiled headers:

add_precompiled_header(target pchheader.h FORCEINCLUDE)

Additional documentation is in PrecompiledHeader.cmake.

About

Visual Studio and GCC precompiled header macro for CMake


Languages

Language:CMake 67.5%Language:Batchfile 12.2%Language:C++ 8.1%Language:C 6.2%Language:Shell 6.0%