From 194f9b0d8a8cfa583285605b8c81cb435109a0a8 Mon Sep 17 00:00:00 2001 From: Camden Narzt Date: Wed, 29 Nov 2023 16:11:48 -0700 Subject: [PATCH] clang < 13 has broken c++20 --- Makefile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c40cc8d..49e2888 100644 --- a/Makefile +++ b/Makefile @@ -14,9 +14,18 @@ LIB_DIR = lib PREFIX := /usr/local CXX=clang++ CPPFLAGS += -MMD -MP -CXXFLAGS := --std=c++20 -O3 -Iinclude + +COMPILER_VERSION := $(shell $(CXX) --version | grep version | grep -o -m 1 "[0-9]\+\.[0-9]\+\.*[0-9]*" | head -n 1) +COMPILER_VERSION_NUMBER := $(shell echo $(COMPILER_VERSION) | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/') +CLANG_13_OR_MORE := $(shell expr $(COMPILER_VERSION_NUMBER) \>= 130000) +ifneq ($(CLANG_13_OR_MORE),0) # supported: c++11, c++14, c++17, c++20 # future: c++2b +CXXFLAGS := --std=c++20 -O3 -Iinclude +else +CXXFLAGS := --std=c++17 -O3 -Iinclude +endif + EXTRA_CXXFLAGS := -pedantic-errors -Weverything -Wno-c++98-compat -Wno-pre-c++20-compat-pedantic -Wno-poison-system-directories LDFLAGS += -Llib -fvisibility=default -fPIC LDLIBS += -lgetargv