--- /dev/null
+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"
+)
+
+++ /dev/null
-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