47 lines
1.1 KiB
Makefile
47 lines
1.1 KiB
Makefile
SHELL:=/bin/bash
|
|
BUILD_DIR:=bin
|
|
PROJECT_NAME:=bettola
|
|
EXECUTABLE:=$(BUILD_DIR)/$(PROJECT_NAME)
|
|
|
|
CXX_COMPILER:=clang++
|
|
CMAKE_MAKEFILE:=$(BUILD_DIR)/Makefile
|
|
|
|
.PHONY: all build config run clean help
|
|
|
|
# Default.
|
|
all: build
|
|
|
|
# Build project, if not configured, then do that first.
|
|
build: $(CMAKE_MAKEFILE)
|
|
@echo "==== Building Bettola ===="
|
|
@cmake --build $(BUILD_DIR)
|
|
|
|
# run 'config' target if the build directory or CMake cache is missing.
|
|
$(CMAKE_MAKEFILE):
|
|
$(MAKE) config
|
|
|
|
config:
|
|
@echo "==== Configuring Bettola with CMake ===="
|
|
@mkdir -p $(BUILD_DIR)
|
|
@cmake -S . -B$(BUILD_DIR) -DCMAKE_CXX_COMPILER=$(CXX_COMPILER) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
|
|
|
# Build and run.
|
|
run: all
|
|
@echo "==== Running Bettola ===="
|
|
$(EXECUTABLE)
|
|
|
|
# Remove build dir.
|
|
clean:
|
|
@echo "==== Cleaning Bettola ===="
|
|
@rm -rf $(BUILD_DIR)
|
|
@echo "==== Project Cleaned ===="
|
|
|
|
help:
|
|
@echo "Available commands:"
|
|
@echo " make - Build the project (default)."
|
|
@echo " make build - Build the project."
|
|
@echo " make run - Build and run the project."
|
|
@echo " make config - Force CMake to re-configure the project."
|
|
@echo " make clean - Remove all build files"
|
|
|