chore: add project framework

main
Jef Roosens 2022-12-03 22:50:32 +01:00
parent 342f977ac7
commit 65d67b2c01
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
7 changed files with 82 additions and 6 deletions

2
.gitignore vendored 100644
View File

@ -0,0 +1,2 @@
build/
compile_commands.json

17
CMakeLists.txt 100644
View File

@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 3.20)
project(cieter C)
set(CMAKE_C_STANDARD 17)
find_package(LibArchive REQUIRED)
include_directories(include)
file(GLOB SRCS src/*.c)
if(CMAKE_BUILD_TYPE STREQUAL Release)
add_compile_options(-O3 -flto)
endif()
add_executable(cieter ${SRCS})
target_link_libraries(cieter LibArchive::LibArchive)

54
Makefile 100644
View File

@ -0,0 +1,54 @@
# =====CONFIG=====
BUILD_DIR := ./build
SRC_DIR := ./src
INCLUDE_DIR := ./include
TEST_DIR := test
CORES != nproc
# =====RECIPES=====
all: build
.PHONY: cmake
cmake: $(BUILD_DIR)/Debug/Makefile
$(BUILD_DIR)/Debug/Makefile: CMakeLists.txt
@ cmake -B'$(BUILD_DIR)/Debug' -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 .
@ ln -sf '$(BUILD_DIR)/Debug/compile_commands.json' compile_commands.json
.PHONY: cmake-test
cmake-test: $(BUILD_DIR)/Test/Makefile
$(BUILD_DIR)/Test/Makefile: CMakeLists.txt
@ cmake -B'$(BUILD_DIR)/Test' -DCMAKE_BUILD_TYPE=Test .
.PHONY: build
build: cmake
@ make -C '$(BUILD_DIR)/Debug'
.PHONY: build-test
build-test: cmake-test
@ make -C '$(BUILD_DIR)/Test'
.PHONY: cmake-release
cmake-release: $(BUILD_DIR)/Release/Makefile
$(BUILD_DIR)/Release/Makefile: CMakeLists.txt
@ cmake -B'$(BUILD_DIR)/Release' -DCMAKE_BUILD_TYPE=Release .
.PHONY: prod
prod: cmake-release
@ make -C '$(BUILD_DIR)/Release'
.PHONY: test
test: build-test
@ $(MAKE) -C '$(BUILD_DIR)/Test' test ARGS=-j$(CORES) CTEST_OUTPUT_ON_FAILURE=1
.PHONY: clean
clean:
@ rm -rf '$(BUILD_DIR)' compile_commands.json
# .PHONY: lint
# lint:
# @ clang-format --Werror -n $(SRCS)
# .PHONY: format
# format:
# @ clang-format -i $(SRCS)

View File

@ -1,5 +1,5 @@
#ifndef VIETER_DYNARRAY
#define VIETER_DYNARRAY
#ifndef CIETER_DYNARRAY
#define CIETER_DYNARRAY
#include <stdlib.h>
#include <string.h>

View File

@ -1,5 +1,5 @@
#ifndef VIETER_PACKAGE
#define VIETER_PACKAGE
#ifndef CIETER_PACKAGE
#define CIETER_PACKAGE
#include <stdint.h>
#include <stdbool.h>

View File

@ -1,5 +1,5 @@
#ifndef VIETER_PACKAGE_INFO
#define VIETER_PACKAGE_INFO
#ifndef CIETER_PACKAGE_INFO
#define CIETER_PACKAGE_INFO
#define FREE_STRING(sp) if (sp != NULL) free(sp)

3
src/main.c 100644
View File

@ -0,0 +1,3 @@
int main() {
}