Tidied up Makefile; fixed compile commands not generating

master
Jef Roosens 2020-11-07 15:29:13 +01:00
parent 584bcb94d1
commit 7c43bcb2d8
2 changed files with 20 additions and 12 deletions

View File

@ -10,39 +10,50 @@ all: debug
clean:
@ rm -rf $(BUILD_DIR)
@ [ ! -e '$(BINARY)' ] || rm '$(BINARY)'
@ rm -rf '$(BUILD_DIR)'
.PHONY: clean
# Release
run-release: release
@ ./$(RELEASE_DIR)/$(BINARY)
@ ./'$(RELEASE_DIR)/$(BINARY)'
.PHONY: run-release
release: $(RELEASE_DIR)/Makefile
@ make -C $(RELEASE_DIR) -j$(CORES)
@ make -C '$(RELEASE_DIR)' -j'$(CORES)' && \
ln -sf '$(RELEASE_DIR)'/'$(BINARY)' ./'$(BINARY)'
.PHONY: release
$(RELEASE_DIR)/Makefile: $(SRC_DIR)/CMakeLists.txt
@ cmake -H$(SRC_DIR) -B$(RELEASE_DIR) -DCMAKE_BUILD_TYPE=Release
@ cmake \
-H'$(SRC_DIR)' \
-B'$(RELEASE_DIR)' \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
clean-release:
@ rm -rf $(RELEASE_DIR)
@ rm -rf '$(RELEASE_DIR)'
.PHONY: clean-release
# Debug
run-debug: debug
@ ./$(DEBUG_DIR)/$(BINARY)
@ ./'$(DEBUG_DIR)/$(BINARY)'
.PHONY: run-debug
debug: $(DEBUG_DIR)/Makefile
@ make -C $(DEBUG_DIR) -j$(CORES)
@ make -C '$(DEBUG_DIR)' -j'$(CORES)' && \
ln -sf '$(DEBUG_DIR)/$(BINARY)' ./'$(BINARY)'
.PHONY: debug
$(DEBUG_DIR)/Makefile: $(SRC_DIR)/CMakeLists.txt
@ cmake -H$(SRC_DIR) -B$(DEBUG_DIR) -DCMAKE_BUILD_TYPE=Debug
@ cmake \
-H'$(SRC_DIR)' \
-B'$(DEBUG_DIR)' \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
clean-debug:
@ rm -rf $(DEBUG_DIR)
@ rm -rf '$(DEBUG_DIR)'
.PHONY: clean-debug

View File

@ -5,9 +5,6 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# Create compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# =====COMPILER=====
set(CMAKE_C_COMPILER "clang-10")