初始化构建配置
This commit is contained in:
11
.clang-format
Normal file
11
.clang-format
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# -*- mode: yaml; -*-
|
||||||
|
|
||||||
|
---
|
||||||
|
BasedOnStyle: Google
|
||||||
|
IndentWidth: 2
|
||||||
|
ConstructorInitializerIndentWidth: 2
|
||||||
|
ContinuationIndentWidth: 2
|
||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
PointerAlignment: Right
|
||||||
|
---
|
||||||
4
.clangd
Normal file
4
.clangd
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# -*- mode: yaml; -*-
|
||||||
|
|
||||||
|
Completion:
|
||||||
|
ArgumentLists: None
|
||||||
20
.editorconfig
Normal file
20
.editorconfig
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*.{c,h}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[.clangd]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.cmake]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
[CMakeLists.txt]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
[Makefile]
|
||||||
|
indent_style = tab
|
||||||
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
/.cache/
|
||||||
|
/build/
|
||||||
|
/compile_commands.json
|
||||||
|
/zswm
|
||||||
43
Makefile
Normal file
43
Makefile
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
MAKEFILE_ABS_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||||
|
MAKEFILE_DIR := $(dir $(MAKEFILE_ABS_PATH))
|
||||||
|
PWD_DIR := $(CURDIR)/
|
||||||
|
BUILD_DIR := $(addprefix $(MAKEFILE_DIR),build)
|
||||||
|
SRC_DIR := $(addprefix $(MAKEFILE_DIR),src/)
|
||||||
|
|
||||||
|
TARGET_NAME := zswm
|
||||||
|
TARGET := $(addprefix $(MAKEFILE_DIR),$(TARGET_NAME))
|
||||||
|
|
||||||
|
ifneq ($(PWD_DIR),$(MAKEFILE_DIR))
|
||||||
|
TARGET := $(addprefix $(MAKEFILE_DIR),$(TARGET_NAME))
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
$(TARGET_NAME): build
|
||||||
|
|
||||||
|
clean:
|
||||||
|
${RM} $(TARGET)
|
||||||
|
${RM} -r $(BUILD_DIR)
|
||||||
|
|
||||||
|
run:
|
||||||
|
-$(shell Xephyr :3 -screen 1920x1080 &)
|
||||||
|
|
||||||
|
wm: $(TARGET_NAME)
|
||||||
|
DISPLAY=:3 $(TARGET)
|
||||||
|
|
||||||
|
prepare:
|
||||||
|
@cmake -S $(SRC_DIR) -B $(BUILD_DIR)
|
||||||
|
@cp $(BUILD_DIR)/compile_commands.json $(MAKEFILE_DIR)
|
||||||
|
|
||||||
|
build: prepare
|
||||||
|
@cmake --build $(BUILD_DIR)
|
||||||
|
@cp $(BUILD_DIR)/$(TARGET_NAME) $(TARGET)
|
||||||
|
|
||||||
|
install: $(TARGET_NAME)
|
||||||
|
@cp $(BUILD_DIR)/$(TARGET_NAME) ~/.local/bin/$(TARGET_NAME)
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
${RM} -r ~/.local/bin/$(TARGET_NAME)
|
||||||
|
|
||||||
|
reinstall: uninstall install
|
||||||
|
|
||||||
|
.PHONY: clean run wm prepare build install uninstall reinstall
|
||||||
20
src/CMakeLists.txt
Normal file
20
src/CMakeLists.txt
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.24)
|
||||||
|
|
||||||
|
set(APP_NAME "zswm")
|
||||||
|
|
||||||
|
# generate compile_commands.json for clangd
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
|
# compile flags
|
||||||
|
add_compile_options(-g)
|
||||||
|
add_compile_options(-Wall)
|
||||||
|
|
||||||
|
project(${APP_NAME}
|
||||||
|
VERSION 0.0.1
|
||||||
|
LANGUAGES C
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(${APP_NAME} main.c)
|
||||||
|
|
||||||
|
# use C17
|
||||||
|
set_property(TARGET ${APP_NAME} PROPERTY C_STANDARD 17)
|
||||||
1
src/main.c
Normal file
1
src/main.c
Normal file
@@ -0,0 +1 @@
|
|||||||
|
int main(int argc, char *argv[]) { return 0; }
|
||||||
Reference in New Issue
Block a user