Skip to content

Commit

Permalink
update to use logic to check compiler version for c++17 compatability
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveBronder committed May 16, 2024
1 parent 9b71558 commit e43440c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions make/compiler_flags
Original file line number Diff line number Diff line change
Expand Up @@ -120,35 +120,45 @@ INC_GTEST ?= -I $(GTEST)/include -I $(GTEST)
CPPFLAGS_BOOST ?= -DBOOST_DISABLE_ASSERTS
CPPFLAGS_SUNDIALS ?= -DNO_FPRINTF_OUTPUT $(CPPFLAGS_OPTIM_SUNDIALS) $(CXXFLAGS_FLTO_SUNDIALS)
#CPPFLAGS_GTEST ?=

HAS_CXX17 := false
ifeq ($(CXX_TYPE), gcc)
GCC_GE_73 := $(shell [ $(CXX_MAJOR) -gt 7 -o \( $(CXX_MAJOR) -eq 7 -a $(CXX_MINOR) -ge 1 \) ] && echo true)
ifeq ($(GCC_GE_73),true)
CXXFLAGS_LANG ?= -std=c++17
CXXFLAGS_STANDARD ?= c++17
HAS_CXX17 := true
endif
else ifeq ($(CXX_TYPE), clang)
CLANG_GE_5 := $(shell [ $(CXX_MAJOR) -gt 5 -o \( $(CXX_MAJOR) -eq 5 -a $(CXX_MINOR) -ge 0 \) ] && echo true)
ifeq ($(CLANG_GE_5),true)
CXXFLAGS_LANG ?= -std=c++17
CXXFLAGS_STANDARD ?= c++17
HAS_CXX17 := true
endif
else ifeq ($(CXX_TYPE), mingw32-gcc)
MINGW_GE_50 := $(shell [ $(CXX_MAJOR) -gt 5 -o \( $(CXX_MAJOR) -eq 5 -a $(CXX_MINOR) -ge 0 \) ] && echo true)
ifeq ($(MINGW_GE_50),true)
CXXFLAGS_LANG ?= -std=c++17
CXXFLAGS_STANDARD ?= c++17
HAS_CXX17 := true
endif
else ifeq ($(STAN_USE_CPP14),)
CXXFLAGS_LANG ?= -std=c++17
CXXFLAGS_STANDARD ?= c++17
HAS_CXX17 := true
else
$(warning "Because STAN_USE_CPP14 is set C++14 standard is requested. This will not be possible in the next release!")
CXXFLAGS_LANG ?= -std=c++1y
CXXFLAGS_STANDARD ?= c++1y
HAS_CXX17 := true
endif


ifeq ($(HAS_CXX17), false)
$(warning "Because STAN_USE_CPP14 is set C++14 standard is requested. This will not be possible in the next release!")
CXXFLAGS_LANG ?= -std=c++1y
CXXFLAGS_STANDARD ?= c++1y
HAS_CXX17 := true
endif
#CXXFLAGS_BOOST ?=
CXXFLAGS_SUNDIALS ?= -pipe $(CXXFLAGS_OPTIM_SUNDIALS) $(CPPFLAGS_FLTO_SUNDIALS)
#CXXFLAGS_GTEST
Expand Down

0 comments on commit e43440c

Please sign in to comment.