Below is a basic Makefile where I am attempting to ascertain if I have a 'modern' g++ compiler that supports C++11. In the past, this worked fine, but now that I have version g++ 11.3.0, it does not.
Code:
ifndef CXX
CXX = g++
endif
GCC_VERSION := $(shell $(CXX) -dumpversion)
ifeq ($(shell expr $(GCC_VERSION) '>=' 4.5), 1)
CXXFLAGS += -std=c++11
endif
foo:
@echo "GCC_VERSION is: $(GCC_VERSION)"
@echo "CXXFLAGS are : $(CXXFLAGS)"
I've tried using 'test' in lieu of 'expr', but it only allows numeric (integer) values.
Is there a better way to ascertain if the compiler supports C++11?