build: re-enable PCH with CCache
Includes: - disable PCH validation when using XCode - disable Clang's PCH timestamping - add ostream header to the PCH
This commit is contained in:
@@ -4,15 +4,15 @@
|
||||
cmake_minimum_required(VERSION 3.10..3.10)
|
||||
|
||||
# Use ccache if available
|
||||
mark_as_advanced(CCACHE_FOUND)
|
||||
mark_as_advanced(CCACHE)
|
||||
find_program(CCACHE ccache)
|
||||
if(NOT ("${CCACHE}" STREQUAL "CCACHE-NOTFOUND"))
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
||||
message(
|
||||
STATUS "CCache is enabled. Precompiled headers are disabled by default."
|
||||
)
|
||||
set(NS3_PRECOMPILE_HEADERS OFF
|
||||
CACHE BOOL "Precompile module headers to speed up compilation" FORCE
|
||||
message(STATUS "CCache is enabled.")
|
||||
execute_process(
|
||||
COMMAND
|
||||
${CCACHE} --set-config
|
||||
sloppiness=pch_defines,time_macros,include_file_mtime,include_file_ctime
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1236,6 +1236,17 @@ macro(process_options)
|
||||
endif()
|
||||
|
||||
if(${PRECOMPILE_HEADERS_ENABLED})
|
||||
if(CLANG)
|
||||
# Clang adds a timestamp to the PCH, which prevents ccache from working
|
||||
# correctly
|
||||
# https://github.com/ccache/ccache/issues/539#issuecomment-664198545
|
||||
add_definitions(-Xclang -fno-pch-timestamp)
|
||||
endif()
|
||||
if(${XCODE})
|
||||
# XCode is weird and messes up with the PCH, requiring this flag
|
||||
# https://github.com/ccache/ccache/issues/156
|
||||
add_definitions(-Xclang -fno-validate-pch)
|
||||
endif()
|
||||
set(precompiled_header_libraries
|
||||
<algorithm>
|
||||
<cstdlib>
|
||||
@@ -1247,6 +1258,7 @@ macro(process_options)
|
||||
<list>
|
||||
<map>
|
||||
<math.h>
|
||||
<ostream>
|
||||
<set>
|
||||
<sstream>
|
||||
<stdint.h>
|
||||
|
||||
Reference in New Issue
Block a user