@@ -70,7 +70,6 @@ CXX_VERSION := $(shell $(CXX) -dumpfullversion -dumpversion 2>&1)
70
70
CXX_MAJOR := $(word 1,$(subst ., ,$(CXX_VERSION)))
71
71
CXX_MINOR := $(word 2,$(subst ., ,$(CXX_VERSION)))
72
72
73
-
74
73
################################################################################
75
74
# Set optional compiler flags for performance
76
75
#
@@ -121,10 +120,32 @@ INC_GTEST ?= -I $(GTEST)/include -I $(GTEST)
121
120
CPPFLAGS_BOOST ?= -DBOOST_DISABLE_ASSERTS
122
121
CPPFLAGS_SUNDIALS ?= -DNO_FPRINTF_OUTPUT $(CPPFLAGS_OPTIM_SUNDIALS) $(CXXFLAGS_FLTO_SUNDIALS)
123
122
#CPPFLAGS_GTEST ?=
123
+ STAN_HAS_CXX17 ?= false
124
+ ifeq ($(CXX_TYPE), gcc)
125
+ GCC_GE_73 := $(shell [ $(CXX_MAJOR) -gt 7 -o \( $(CXX_MAJOR) -eq 7 -a $(CXX_MINOR) -ge 1 \) ] && echo true)
126
+ ifeq ($(GCC_GE_73),true)
127
+ STAN_HAS_CXX17 := true
128
+ endif
129
+ else ifeq ($(CXX_TYPE), clang)
130
+ CLANG_GE_5 := $(shell [ $(CXX_MAJOR) -gt 5 -o \( $(CXX_MAJOR) -eq 5 -a $(CXX_MINOR) -ge 0 \) ] && echo true)
131
+ ifeq ($(CLANG_GE_5),true)
132
+ STAN_HAS_CXX17 := true
133
+ endif
134
+ else ifeq ($(CXX_TYPE), mingw32-gcc)
135
+ MINGW_GE_50 := $(shell [ $(CXX_MAJOR) -gt 5 -o \( $(CXX_MAJOR) -eq 5 -a $(CXX_MINOR) -ge 0 \) ] && echo true)
136
+ ifeq ($(MINGW_GE_50),true)
137
+ STAN_HAS_CXX17 := true
138
+ endif
139
+ endif
124
140
125
-
126
- ## setup compiler flags
127
- CXXFLAGS_LANG ?= -std=c++1y
141
+ ifeq ($(STAN_HAS_CXX17), true)
142
+ CXXFLAGS_LANG ?= -std=c++17
143
+ CXXFLAGS_STANDARD ?= c++17
144
+ else
145
+ $(warning "Stan cannot detect if your compiler has the C++17 standard. If it does, please set STAN_HAS_CXX17=true in your make/local file. C++17 support is mandatory in the next release of Stan. Defaulting to C++14")
146
+ CXXFLAGS_LANG ?= -std=c++1y
147
+ CXXFLAGS_STANDARD ?= c++1y
148
+ endif
128
149
#CXXFLAGS_BOOST ?=
129
150
CXXFLAGS_SUNDIALS ?= -pipe $(CXXFLAGS_OPTIM_SUNDIALS) $(CPPFLAGS_FLTO_SUNDIALS)
130
151
#CXXFLAGS_GTEST
0 commit comments