Put PCH behind a cmake flag

Allows developers to turn it off if they don't like/don't want it
This commit is contained in:
Seth Hillbrand 2025-07-30 17:04:06 -07:00
parent 2aad11e3e7
commit 5b3d4fc91d
5 changed files with 66 additions and 47 deletions

View File

@ -233,6 +233,10 @@ cmake_dependent_option( KICAD_WIN32_LTCG
OFF "WIN32"
OFF )
option( KICAD_USE_PCH
"Enable precompiled header support"
ON )
# Advanced option to make link maps (only available on linux)
cmake_dependent_option( KICAD_MAKE_LINK_MAPS
"Create link maps for artifacts"

View File

@ -239,18 +239,20 @@ add_library( kicommon SHARED
${KICOMMON_SRCS}
)
target_precompile_headers( kicommon
PRIVATE
<kicommon.h>
<algorithm>
<map>
<memory>
<optional>
<set>
<string>
<vector>
<wx/wx.h>
)
if( KICAD_USE_PCH )
target_precompile_headers( kicommon
PRIVATE
<kicommon.h>
<algorithm>
<map>
<memory>
<optional>
<set>
<string>
<vector>
<wx/wx.h>
)
endif()
set_target_properties(kicommon PROPERTIES CXX_VISIBILITY_PRESET hidden)
@ -750,18 +752,20 @@ add_library( common STATIC
${COMMON_SRCS}
)
target_precompile_headers( kicommon
PRIVATE
<kicommon.h>
<algorithm>
<map>
<memory>
<optional>
<set>
<string>
<vector>
<wx/wx.h>
)
if( KICAD_USE_PCH )
target_precompile_headers( kicommon
PRIVATE
<kicommon.h>
<algorithm>
<map>
<memory>
<optional>
<set>
<string>
<vector>
<wx/wx.h>
)
endif()
add_dependencies( common version_header )
add_dependencies( common compoundfilereader ) # used by altium_parser.cpp
@ -929,17 +933,19 @@ set( PCB_COMMON_SRCS
add_library( pcbcommon STATIC ${PCB_COMMON_SRCS} )
target_precompile_headers( pcbcommon
PRIVATE
<vector>
<map>
<memory>
<unordered_map>
<board.h>
<footprint.h>
<zone.h>
<connectivity/connectivity_data.h>
<drc/drc_engine.h> )
if( KICAD_USE_PCH )
target_precompile_headers( pcbcommon
PRIVATE
<vector>
<map>
<memory>
<unordered_map>
<board.h>
<footprint.h>
<zone.h>
<connectivity/connectivity_data.h>
<drc/drc_engine.h> )
endif()
target_compile_definitions(pcbcommon PRIVATE PCBNEW)

View File

@ -317,6 +317,13 @@ wxString GetVersionInfoData( const wxString& aTitle, bool aHtml, bool aBrief )
aMsg << indent4 << "KICAD_IPC_API=" << OFF;
#endif
aMsg << indent4 << "KICAD_USE_PCH=";
#ifdef KICAD_USE_PCH
aMsg << ON;
#else
aMsg << OFF;
#endif
#ifndef NDEBUG
aMsg << indent4 << "KICAD_STDLIB_DEBUG=";
#ifdef KICAD_STDLIB_DEBUG

View File

@ -576,17 +576,19 @@ add_library( eeschema_kiface_objects OBJECT
${EESCHEMA_COMMON_SRCS}
)
target_precompile_headers( eeschema_kiface_objects
PRIVATE
<vector>
<map>
<memory>
<unordered_map>
<sch_edit_frame.h>
<string_utils.h>
<schematic.h>
<pgm_base.h>
<wx/wx.h> )
if( KICAD_USE_PCH )
target_precompile_headers( eeschema_kiface_objects
PRIVATE
<vector>
<map>
<memory>
<unordered_map>
<sch_edit_frame.h>
<string_utils.h>
<schematic.h>
<pgm_base.h>
<wx/wx.h> )
endif()
target_include_directories( eeschema_kiface_objects
PUBLIC

View File

@ -720,7 +720,7 @@ add_library( pcbnew_kiface_objects OBJECT
${PCBNEW_SCRIPTING_SRCS}
)
if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
if( KICAD_USE_PCH AND CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
target_precompile_headers( pcbnew_kiface_objects
PRIVATE
<vector>