Skip to content

jkriege2/cmake-precompiled-header

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • CMake 67.5%
  • Batchfile 12.2%
  • C++ 8.1%
  • C 6.2%
  • Shell 6.0%