You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
840 B
Makefile

CXX := clang++
CXXFLAGS := -std=c++23 -O2 -Wall -Wextra -Werror -Ilib
SRC_DIR := src
LIB_DIR := lib
OUT_DIR := out
PROJECTS := $(wildcard $(SRC_DIR)/*)
BINS := $(patsubst $(SRC_DIR)/%, $(OUT_DIR)/%, $(PROJECTS))
LIB_SOURCES := $(wildcard $(LIB_DIR)/*.cpp)
# checking with a silly test program whether openmp is accessible
# maybe at some point a cmake file would be more elegant.
OPENMP_FLAG :=
OPENMP_CHECK := $(shell printf '#include <omp.h>\nint main(){return 0;}' | \
$(CXX) -std=c++23 -fopenmp -x c++ - -o /dev/null 2>/dev/null && echo yes)
ifeq ($(OPENMP_CHECK),yes)
OPENMP_FLAG := -fopenmp
endif
CXXFLAGS += $(OPENMP_FLAG)
all: $(BINS)
$(OUT_DIR)/%: $(SRC_DIR)/% $(LIB_SOURCES) | $(OUT_DIR)
$(CXX) $(CXXFLAGS) $</*.cpp $(LIB_SOURCES) -o $@
$(OUT_DIR):
mkdir -p $(OUT_DIR)
clean:
rm -rf $(OUT_DIR)
.PHONY: all clean