🧱 Neatly separated code into projects and libraries.

Isabell Pflug 2 days ago
parent 1b241cd05b
commit db12710281

@ -1,30 +1,22 @@
# Pfad zum Makefile selbst bestimmen
MAKEFILE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
CXX := clang++ CXX := clang++
CXXFLAGS := -Wall -Wextra -Wpedantic -O2 -std=c++23 CXXFLAGS := -std=c++23 -O2 -Wall -Wextra -Werror -fopenmp -Ilib
SRC_DIR := $(MAKEFILE_DIR)/src
OUT_DIR := $(MAKEFILE_DIR)/out
SOURCES := $(wildcard $(SRC_DIR)/*.cpp) SRC_DIR := src
TARGETS := $(patsubst $(SRC_DIR)/%.cpp,$(OUT_DIR)/%,$(SOURCES)) LIB_DIR := lib
OUT_DIR := out
# Teste ob Compiler C++23 kann PROJECTS := $(wildcard $(SRC_DIR)/*)
CXX23_SUPPORTED := $(shell echo 'int main(){}' | $(CXX) -std=c++23 -x c++ -o /dev/null - 2>/dev/null && echo yes) BINS := $(patsubst $(SRC_DIR)/%, $(OUT_DIR)/%, $(PROJECTS))
LIB_SOURCES := $(wildcard $(LIB_DIR)/*.cpp)
ifeq ($(CXX23_SUPPORTED),) all: $(BINS)
$(error Your compiler does not support C++23. Please update your system!)
endif
all: $(OUT_DIR) $(TARGETS) $(OUT_DIR)/%: $(SRC_DIR)/% $(LIB_SOURCES) | $(OUT_DIR)
$(CXX) $(CXXFLAGS) $</*.cpp $(LIB_SOURCES) -o $@
$(OUT_DIR): $(OUT_DIR):
mkdir -p $(OUT_DIR) mkdir -p $(OUT_DIR)
$(OUT_DIR)/%: $(SRC_DIR)/%.cpp
$(CXX) $(CXXFLAGS) $< -o $@
clean: clean:
rm -rf $(OUT_DIR) rm -rf $(OUT_DIR)

Loading…
Cancel
Save