From 2da54ed285c5da913c9fb11e0b0410becccb8a39 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Mon, 25 Apr 2022 11:46:14 +0200 Subject: [PATCH] Use CMake --- .gitignore | 15 ++++++++++++++- CMakeLists.txt | 20 ++++++++++++++++++++ Makefile | 23 ----------------------- 3 files changed, 34 insertions(+), 24 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 Makefile diff --git a/.gitignore b/.gitignore index f01a0a0..3d4b7d4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,15 @@ -linenoise_example +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps +*.a *.exe +linenoise_example +linenoise_utf8_example diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..4a75aa0 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.14) +project(Linenoise) + +add_library(linenoise + linenoise.c + stringbuf.c + utf8.c +) + +target_include_directories(linenoise + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} +) + +add_executable(linenoise_example example.c) +target_link_libraries(linenoise_example linenoise) + +add_executable(linenoise_utf8_example example.c) +target_link_libraries(linenoise_utf8_example linenoise) +target_compile_definitions(linenoise_utf8_example PUBLIC USE_UTF8) + diff --git a/Makefile b/Makefile deleted file mode 100644 index d8746ab..0000000 --- a/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -CFLAGS += -Wall -W -Os -g -CC ?= gcc - -all: linenoise_example linenoise_utf8_example - -linenoise_example: linenoise.h linenoise-ship.c linenoise-win32.c example.c - $(CC) $(CFLAGS) -o $@ linenoise-ship.c example.c - -linenoise_utf8_example: linenoise.h linenoise-ship.c linenoise-win32.c - $(CC) $(CFLAGS) -DUSE_UTF8 -o $@ linenoise-ship.c example.c - -clean: - rm -f linenoise_example linenoise_utf8_example linenoise-ship.c *.o - -ship: linenoise-ship.c - -# linenoise-ship.c simplifies delivery of linenoise support -# simple copy linenoise-ship.c to linenoise.c in your application, and also linenoise.h -# - If you want win32 support, also copy linenoise-win32.c -# - If you never want to support utf-8, you can omit utf8.h and utf8.c - -linenoise-ship.c: utf8.h utf8.c stringbuf.h stringbuf.c linenoise.c - cat $^ >$@ -- 2.44.0