From 7eda4ae5511f7270e148823965ec030b101459e9 Mon Sep 17 00:00:00 2001 From: Omkar Yadav Date: Fri, 22 Mar 2019 23:54:51 +0530 Subject: [PATCH 1/4] CMake file for the CMake support --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..f657507 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.3) + +project(minmea) + +set(core_SRCS minmea.c minmea.h) +add_library(core ${core_SRCS}) +add_executable(exe example.c) +target_link_libraries(exe core) From 2b8b64c784a29078b1eabbc830c128c28acd9918 Mon Sep 17 00:00:00 2001 From: Kosma Moczek Date: Thu, 2 Jun 2022 23:09:17 +0200 Subject: [PATCH 2/4] Full CMake support --- .gitignore | 1 + CMakeLists.txt | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index dd53256..8b77ca0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +build/ *.o *~ *.diff diff --git a/CMakeLists.txt b/CMakeLists.txt index f657507..de45c10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,18 @@ cmake_minimum_required(VERSION 3.3) project(minmea) -set(core_SRCS minmea.c minmea.h) -add_library(core ${core_SRCS}) -add_executable(exe example.c) -target_link_libraries(exe core) +find_package(Threads REQUIRED) # Workaround for https://github.com/libcheck/check/issues/48#issuecomment-322965461 +find_package(PkgConfig) +pkg_check_modules(CHECK REQUIRED check) + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -Werror -std=c99") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_DARWIN_C_SOURCE") + +set(minmea_SRCS minmea.c minmea.h) +add_library(minmea ${minmea_SRCS}) +add_executable(example example.c) +add_executable(tests tests.c) +target_link_libraries(example minmea) +target_link_libraries(tests minmea ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) +target_include_directories(tests PUBLIC ${CHECK_INCLUDE_DIRS}) +target_compile_options(tests PUBLIC ${CHECK_CFLAGS_OTHER}) From 8e5aaabd03f651a8823f02916afcfb04c26b3565 Mon Sep 17 00:00:00 2001 From: Kosma Moczek Date: Thu, 2 Jun 2022 23:14:42 +0200 Subject: [PATCH 3/4] .github: add CMake run --- .github/workflows/c-cpp.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index c0bcc0f..04adf7c 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -8,6 +8,8 @@ jobs: steps: - uses: actions/checkout@v3 - name: Install dependencies - run: sudo apt-get install -y clang-tools check + run: sudo apt-get install -y clang-tools check cmake - name: make run: make + - name: cmake + run: "( rm -rf build && mkdir build && cd build && cmake .. && make && ./tests && echo OK )" From 34556192b921142c030d216c3763f6ccca233863 Mon Sep 17 00:00:00 2001 From: Kosma Moczek Date: Thu, 2 Jun 2022 23:30:28 +0200 Subject: [PATCH 4/4] .gitignore: ignore CLion build directory --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8b77ca0..a419ab1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ build/ +cmake-build-*/ *.o *~ *.diff