libdraw

Minimal window and drawing library
git clone http://git.omkov.net/libdraw
Log | Tree | Refs | Download

AuthorJakob Wakeling <[email protected]>
Date2024-03-10 05:59:19
Commit7fd7b2117f51ff042e2fc3f38c6fd00a7c3c005b

Add base project files

Diffstat

A .gitignore | 7 +++++++
A .vscode/launch.json | 30 ++++++++++++++++++++++++++++++
A CMakeLists.txt | 21 +++++++++++++++++++++
A Makefile | 13 +++++++++++++

4 files changed, 71 insertions, 0 deletions

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..51e9dcf
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+/.cache/
+/.vscode/*
+/bin/
+/build/
+/lib/
+
+!/.vscode/launch.json
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..480fd53
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,30 @@
+{
+	"version": "0.2.0",
+	"configurations": [
+		{
+			"name": "Debug",
+			"type": "cppdbg",
+			"request": "launch",
+			"program": "${command:cmake.launchTargetPath}",
+			"args": [],
+			"stopAtEntry": false,
+			"cwd": "${workspaceFolder}",
+			"environment": [],
+			"externalConsole": false,
+			"MIMode": "gdb",
+			"setupCommands": [
+				{
+					"description": "Enable pretty-printing for gdb",
+					"text": "-enable-pretty-printing",
+					"ignoreFailures": true
+				},
+				{
+					"description": "Set Disassembly Flavor to Intel",
+					"text": "-gdb-set disassembly-flavor intel",
+					"ignoreFailures": true
+				}
+			]
+		}
+
+	]
+}
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..293ccbf
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,21 @@
+cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
+project(libdraw LANGUAGES C)
+
+set(CMAKE_C_STANDARD 23)
+set(CMAKE_C_STANDARD_REQUIRED TRUE)
+set(CMAKE_C_EXTENSIONS FALSE)
+
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
+set(CMAKE_STATIC_LIBRARY_PREFIX "")
+set(CMAKE_SHARED_LIBRARY_PREFIX "")
+add_compile_definitions(VERSION="$ENV{VERSION}")
+
+file(GLOB_RECURSE SRC CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/src/*.c)
+
+add_library(libdraw SHARED ${SRC})
+target_link_libraries(libdraw xcb xcb-keysyms)
+
+add_executable(example_draw ${PROJECT_SOURCE_DIR}/examples/draw.c)
+target_link_libraries(example_draw libdraw)
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..e994e06
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,13 @@
+.PHONY: all build test help
+all: help
+
+build: ## Build the project
+	@cmake -S . -B ./build -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=1
+	@cmake --build ./build
+
+test: build ## Run unit tests
+	@(cd ./build && ctest)
+
+help: ## Display help information
+	@grep -E '^[a-zA-Z_-]+:.*?##.*$$' $(MAKEFILE_LIST) | \
+		awk 'BEGIN {FS = ":.*?## *"}; {printf "\033[36m%-6s\033[0m %s\n", $$1, $$2}'