2020-09-21 11:28:51 +00:00
|
|
|
PRECOMPILE_HEADERS ?= 0
|
2019-11-06 15:54:18 +00:00
|
|
|
|
|
|
|
print-var-help += \
|
|
|
|
echo " PRECOMPILE_HEADERS ($(PRECOMPILE_HEADERS)): Whether to use precompiled headers to speed up the build";
|
|
|
|
|
|
|
|
GCH = $(buildprefix)precompiled-headers.h.gch
|
|
|
|
|
|
|
|
$(GCH): precompiled-headers.h
|
|
|
|
@rm -f $@
|
|
|
|
@mkdir -p "$(dir $@)"
|
2020-03-30 12:29:29 +00:00
|
|
|
$(trace-gen) $(CXX) -x c++-header -o $@ $< $(GLOBAL_CXXFLAGS) $(GCH_CXXFLAGS)
|
2019-11-06 15:54:18 +00:00
|
|
|
|
|
|
|
PCH = $(buildprefix)precompiled-headers.h.pch
|
|
|
|
|
|
|
|
$(PCH): precompiled-headers.h
|
|
|
|
@rm -f $@
|
|
|
|
@mkdir -p "$(dir $@)"
|
2020-03-30 12:29:29 +00:00
|
|
|
$(trace-gen) $(CXX) -x c++-header -o $@ $< $(GLOBAL_CXXFLAGS) $(GCH_CXXFLAGS)
|
2019-11-06 15:54:18 +00:00
|
|
|
|
|
|
|
clean-files += $(GCH) $(PCH)
|
|
|
|
|
|
|
|
ifeq ($(PRECOMPILE_HEADERS), 1)
|
|
|
|
|
2020-10-06 11:26:00 +00:00
|
|
|
ifeq ($(findstring clang++,$(CXX)), clang++)
|
2019-11-06 15:54:18 +00:00
|
|
|
|
2020-10-06 11:26:00 +00:00
|
|
|
GLOBAL_CXXFLAGS_PCH += -include-pch $(PCH) -Winvalid-pch
|
2019-11-06 15:54:18 +00:00
|
|
|
|
2020-10-06 11:26:00 +00:00
|
|
|
GLOBAL_ORDER_AFTER += $(PCH)
|
2019-11-06 15:54:18 +00:00
|
|
|
|
2020-10-06 11:26:00 +00:00
|
|
|
else ifeq ($(findstring g++,$(CXX)), g++)
|
2019-11-06 15:54:18 +00:00
|
|
|
|
2020-10-06 11:26:00 +00:00
|
|
|
GLOBAL_CXXFLAGS_PCH += -include $(buildprefix)precompiled-headers.h -Winvalid-pch
|
2019-11-06 15:54:18 +00:00
|
|
|
|
2020-10-06 11:26:00 +00:00
|
|
|
GLOBAL_ORDER_AFTER += $(GCH)
|
2019-11-06 15:54:18 +00:00
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
$(error Don't know how to precompile headers on $(CXX))
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
endif
|