On older Xcode/g++ versions the c++20 standard was called c++2a. (#1031)

This commit is contained in:
Eric Warmenhoven 2024-05-09 09:17:50 -04:00 committed by GitHub
parent 6de7ae9dd8
commit 9f13401d0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 28 additions and 0 deletions

View File

@ -60,6 +60,13 @@ endif
GET_STATIC_ARG=$(if $(filter $(shell $(CXX) -print-file-name=$1.a),$1.a),,-static-$1) GET_STATIC_ARG=$(if $(filter $(shell $(CXX) -print-file-name=$1.a),$1.a),,-static-$1)
# Unix # Unix
ifneq (,$(findstring unix,$(platform))) ifneq (,$(findstring unix,$(platform)))
GPP_MAJOR := $(shell $(CXX) -dumpversion | cut -d '.' -f 1)
ifeq ($(GPP_MAJOR),)
$(error Unable to determine $(CXX) version)
endif
ifeq "$(shell [ $(GPP_MAJOR) -lt 10 ]; echo $$?)" "0"
CXXFLAGS := $(subst -std=c++20,-std=c++2a,$(CXXFLAGS))
endif
CXXFLAGS += $(LTO) CXXFLAGS += $(LTO)
LDFLAGS += $(LTO) $(PTHREAD_FLAGS) $(call GET_STATIC_ARG,libgcc) $(call GET_STATIC_ARG,libstdc++) LDFLAGS += $(LTO) $(PTHREAD_FLAGS) $(call GET_STATIC_ARG,libgcc) $(call GET_STATIC_ARG,libstdc++)
TARGET := $(TARGET_NAME)_libretro.so TARGET := $(TARGET_NAME)_libretro.so
@ -81,6 +88,13 @@ ifneq (,$(findstring unix,$(platform)))
# OS X # OS X
else ifeq ($(platform), osx) else ifeq ($(platform), osx)
XCODE_MAJOR := $(shell xcodebuild -version | grep -oE 'Xcode ([0-9]+)' | cut -d ' ' -f 2)
ifeq ($(XCODE_MAJOR),)
$(error Unable to determine Xcode version)
endif
ifeq "$(shell [ $(XCODE_MAJOR) -lt 14 ]; echo $$?)" "0"
CXXFLAGS := $(subst -std=c++20,-std=c++2a,$(CXXFLAGS))
endif
CXXFLAGS += $(LTO) -stdlib=libc++ CXXFLAGS += $(LTO) -stdlib=libc++
LDFLAGS += $(LTO) $(PTHREAD_FLAGS) -stdlib=libc++ LDFLAGS += $(LTO) $(PTHREAD_FLAGS) -stdlib=libc++
TARGET := $(TARGET_NAME)_libretro.dylib TARGET := $(TARGET_NAME)_libretro.dylib
@ -116,6 +130,13 @@ else ifeq ($(platform), osx)
# iOS # iOS
else ifneq (,$(findstring ios,$(platform))) else ifneq (,$(findstring ios,$(platform)))
XCODE_MAJOR := $(shell xcodebuild -version | grep -oE 'Xcode ([0-9]+)' | cut -d ' ' -f 2)
ifeq ($(XCODE_MAJOR),)
$(error Unable to determine Xcode version)
endif
ifeq "$(shell [ $(XCODE_MAJOR) -lt 14 ]; echo $$?)" "0"
CXXFLAGS := $(subst -std=c++20,-std=c++2a,$(CXXFLAGS))
endif
CXXFLAGS += $(LTO) -stdlib=libc++ CXXFLAGS += $(LTO) -stdlib=libc++
LDFLAGS += $(LTO) $(PTHREAD_FLAGS) -stdlib=libc++ LDFLAGS += $(LTO) $(PTHREAD_FLAGS) -stdlib=libc++
TARGET := $(TARGET_NAME)_libretro_ios.dylib TARGET := $(TARGET_NAME)_libretro_ios.dylib
@ -142,6 +163,13 @@ else ifneq (,$(findstring ios,$(platform)))
# tvOS # tvOS
else ifeq ($(platform), tvos-arm64) else ifeq ($(platform), tvos-arm64)
XCODE_MAJOR := $(shell xcodebuild -version | grep -oE 'Xcode ([0-9]+)' | cut -d ' ' -f 2)
ifeq ($(XCODE_MAJOR),)
$(error Unable to determine Xcode version)
endif
ifeq "$(shell [ $(XCODE_MAJOR) -lt 14 ]; echo $$?)" "0"
CXXFLAGS := $(subst -std=c++20,-std=c++2a,$(CXXFLAGS))
endif
CXXFLAGS += $(LTO) $(PTHREAD_FLAGS) -stdlib=libc++ CXXFLAGS += $(LTO) $(PTHREAD_FLAGS) -stdlib=libc++
LDFLAGS += $(LTO) $(PTHREAD_FLAGS) -stdlib=libc++ LDFLAGS += $(LTO) $(PTHREAD_FLAGS) -stdlib=libc++
TARGET := $(TARGET_NAME)_libretro_tvos.dylib TARGET := $(TARGET_NAME)_libretro_tvos.dylib