Skip to content

Commit cdd2791

Browse files
authored
Merge pull request #1268 from stan-dev/makefile/gcc-precompiled-header-finding
2 parents 202c1cc + e923461 commit cdd2791

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

make/program

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,20 @@ $(CMDSTAN_MAIN_O) : $(CMDSTAN_MAIN)
1616
##
1717
# Precompiled model header
1818
##
19-
$(STAN)src/stan/model/model_header$(STAN_FLAGS)_$(CXX_MAJOR)_$(CXX_MINOR).d : $(STAN)src/stan/model/model_header.hpp
19+
$(patsub %.d,%.hpp.gch,$(PRECOMPILED_MODEL_HEADER)) : $(STAN)src/stan/model/model_header.hpp
2020
$(COMPILE.cpp) $(DEPFLAGS) $<
2121

2222
ifneq ($(PRECOMPILED_MODEL_HEADER),)
23-
$(STAN)src/stan/model/model_header$(STAN_FLAGS)_$(CXX_MAJOR)_$(CXX_MINOR).d : DEPTARGETS = -MT $(patsubst %.d,%.hpp.gch,$@) -MT $@
24-
$(STAN)src/stan/model/model_header$(STAN_FLAGS)_$(CXX_MAJOR)_$(CXX_MINOR).hpp.gch : $(STAN)src/stan/model/model_header.hpp
23+
$(patsub %.d,%.hpp.gch,$(PRECOMPILED_MODEL_HEADER)) : DEPTARGETS = -MT $(patsubst %.d,%.hpp.gch,$@) -MT $@
24+
$(PRECOMPILED_MODEL_HEADER) : $(STAN)src/stan/model/model_header.hpp
2525
@echo ''
2626
@echo '--- Compiling pre-compiled header. This might take a few seconds. ---'
27+
@mkdir $(dir $@)
2728
$(COMPILE.cpp) $< $(OUTPUT_OPTION)
2829

2930
ifeq ($(CXX_TYPE),clang)
30-
CXXFLAGS_PROGRAM += -include-pch $(STAN)src/stan/model/model_header$(STAN_FLAGS)_$(CXX_MAJOR)_$(CXX_MINOR).hpp.gch
31-
$(STAN_TARGETS) : %$(EXE) : $(STAN)src/stan/model/model_header$(STAN_FLAGS)_$(CXX_MAJOR)_$(CXX_MINOR).hpp.gch
31+
CXXFLAGS_PROGRAM += -include-pch $(PRECOMPILED_MODEL_HEADER)
32+
$(STAN_TARGETS) : %$(EXE) : $(PRECOMPILED_MODEL_HEADER)
3233
endif
3334
endif
3435

makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ PRECOMPILED_HEADERS ?= true
132132
endif
133133

134134
ifeq ($(PRECOMPILED_HEADERS),true)
135-
PRECOMPILED_MODEL_HEADER=$(STAN)src/stan/model/model_header$(STAN_FLAGS)_$(CXX_MAJOR)_$(CXX_MINOR).hpp.gch
135+
PRECOMPILED_MODEL_HEADER=$(STAN)src/stan/model/model_header.hpp.gch/model_header$(STAN_FLAGS)_$(CXX_MAJOR)_$(CXX_MINOR).hpp.gch
136136
ifeq ($(CXX_TYPE),gcc)
137137
CXXFLAGS_PROGRAM+= -Wno-ignored-attributes $(CXXFLAGS_OPTIM) $(CXXFLAGS_FLTO)
138138
endif
@@ -284,6 +284,7 @@ clean: clean-tests
284284
$(RM) -r bin/cmdstan
285285
@echo ' removing cached compiler objects'
286286
$(RM) $(wildcard src/cmdstan/main*.o) $(wildcard $(STAN)src/stan/model/model_header*.hpp.gch)
287+
$(RM) -r $(STAN)src/stan/model/model_header.hpp.gch/
287288
@echo ' removing built example model'
288289
$(RM) examples/bernoulli/bernoulli$(EXE) examples/bernoulli/bernoulli.o examples/bernoulli/bernoulli.d examples/bernoulli/bernoulli.hpp $(wildcard examples/bernoulli/*.csv)
289290

0 commit comments

Comments
 (0)