]> git repos ~mattia - cmc-find.git/commitdiff
Switched to CMake
authorMattia Cabrini <dev@mattiacabrini.com>
Tue, 9 Sep 2025 19:51:31 +0000 (21:51 +0200)
committerMattia Cabrini <dev@mattiacabrini.com>
Tue, 9 Sep 2025 19:51:31 +0000 (21:51 +0200)
.gitignore [new file with mode: 0644]
CMakeLists.txt [new file with mode: 0644]
Makefile [deleted file]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..d530d57
--- /dev/null
@@ -0,0 +1,5 @@
+cmc-find
+*.swp
+*.BAK
+*.dSYM
+build
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..cecc902
--- /dev/null
@@ -0,0 +1,34 @@
+cmake_minimum_required(VERSION 3.16)
+
+project(cmc-find C)
+
+if(NOT CMAKE_BUILD_TYPE)
+  set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
+endif()
+
+set(SRC cmc-find.c)
+add_executable(cmc-find ${SRC})
+
+target_compile_options(cmc-find PRIVATE
+  -Wall
+  -Werror
+  -Wno-unused-function
+)
+
+target_compile_options(cmc-find PRIVATE
+  $<$<CONFIG:Release>:-O2>
+  $<$<CONFIG:Debug>:-g;-O0>
+)
+
+set(INDENT_FLAGS
+  -nbad -bap -nbc -br -brs -c33 -cd33 -ncdb -ce -ci4
+  -cli0 -d0 -di1 -nfc1 -i8 -ip0 -l80 -lp -npcs -npsl
+  -ncs -nsc -sob -ts8
+)
+
+add_custom_target(fmt
+  COMMAND indent ${INDENT_FLAGS} ${SRC}
+  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+  COMMENT "Formatting sources with indent"
+)
+
diff --git a/Makefile b/Makefile
deleted file mode 100644 (file)
index e47a0f1..0000000
--- a/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-CFLAGS=-Wall -Werror -Wno-unused-function
-CFLAGS_REL=$(CFLSGS) -O2 
-CFLAGS_DEB=$(CFLAGS) -g -O0 
-
-SRC=cmc-find.c
-BIN=cmc-find
-
-INDEND_FLAGS=-nbad -bap -nbc -br -brs -c33 -cd33 -ncdb -ce -ci4 \
-            -cli0 -d0 -di1 -nfc1 -i8 -ip0 -l80 -lp -npcs -npsl \
-            -ncs -nsc -sob -ts8 
-
-all: fmt release
-
-release:
-       gcc -o $(BIN) $(SRC) $(CFLAGS_REL)
-
-debug: 
-       gcc -o $(BIN) $(SRC) $(CFLAGS_DEB) 
-
-fmt:
-       indent $(INDEND_FLAGS) $(SRC)
-
-run: # on Unix-like systems...
-       cat /dev/urandom | ./$(BIN) 1606