From 9ead0a28be7c9daff918319d0929c854e2a4abbd Mon Sep 17 00:00:00 2001 From: Hong Chen Date: Thu, 30 Nov 2023 14:39:00 -0600 Subject: [PATCH] Added case in ICG makefile to use C++17 for clang 16 as clang 16 or later builds C++ code according to the C++17 by default. (#1621) --- trick_source/codegen/Interface_Code_Gen/makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/trick_source/codegen/Interface_Code_Gen/makefile b/trick_source/codegen/Interface_Code_Gen/makefile index a0eb3551..3f3b8538 100644 --- a/trick_source/codegen/Interface_Code_Gen/makefile +++ b/trick_source/codegen/Interface_Code_Gen/makefile @@ -11,11 +11,17 @@ CLANG_PATCHLEVEL := $(shell $(LLVM_HOME)/bin/llvm-config --version | cut -f3 -d. CLANG_MINOR_GTEQ5 := $(shell [ $(CLANG_MAJOR) -gt 3 -o \( $(CLANG_MAJOR) -eq 3 -a $(CLANG_MINOR) -ge 5 \) ] && echo 1) CLANG_MAJOR_GTEQ10 := $(shell [ $(CLANG_MAJOR) -ge 10 ] && echo 1) +# By default, Clang 16 or later builds C++ code according to the C++17 standard. +CLANG_MAJOR_GTEQ16 := $(shell [ $(CLANG_MAJOR) -ge 16 ] && echo 1) +ifeq ($(CLANG_MAJOR_GTEQ16),1) +CXXFLAGS += -std=c++17 +else ifeq ($(CLANG_MAJOR_GTEQ10),1) CXXFLAGS += -std=c++14 else CXXFLAGS += -std=c++11 endif +endif LLVMLDFLAGS := $(shell $(LLVM_HOME)/bin/llvm-config --ldflags) $(UDUNITS_LDFLAGS) @@ -48,8 +54,12 @@ endif ifeq ($(TRICK_HOST_TYPE),Darwin) CLANGLIBS += $(shell $(LLVM_HOME)/bin/llvm-config --libs) CLANGLIBS += $(filter-out -llibxml2.tbd,$(shell $(LLVM_HOME)/bin/llvm-config --system-libs)) +ifeq ($(CLANG_MAJOR_GTEQ16),1) +CLANGLIBS += -lc++abi -lclang-cpp +else CLANGLIBS += -lc++abi endif +endif all: $(ICG)