From a459358120187b7e1ce2c120f4628985d94d2c8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8A=E3=82=8A?= <97130483+ori-d@users.noreply.github.com> Date: Sun, 28 May 2023 08:33:51 +0300 Subject: [PATCH 1/4] Added CMakeLists.txt for support CMake. --- CMakeLists.txt | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..d542030 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,56 @@ +cmake_minimum_required (VERSION 3.16) + +project ("munit" + LANGUAGES C + DESCRIPTION "µnit Testing Library for C" + HOMEPAGE_URL "https://github.com/nemequ/munit" + VERSION 0.2.0) + +option (BUILD_SHARED_LIBS "Build shared library" ON) +option (BUILD_TESTS "Build tests" ON) + +set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + +add_library (munit) + +target_sources (munit + PRIVATE + munit.c) + +target_sources (munit + INTERFACE + munit.h) + +set_target_properties (munit + PROPERTIES + C_STANDARD 99 + C_STANDARD_REQUIRED ON + # to pass only c99 not gnu99 + C_EXTENSIONS OFF) + +configure_file (cmake/munit.pc.in + ${CMAKE_BINARY_DIR}/lib/pkgconfig/munit.pc + @ONLY) + +if (BUILD_EXAMPLE) + add_executable (munit_example) + + target_sources (munit_example + PRIVATE example.c) + + target_link_libraries (munit_example + PRIVATE munit) + + include (CTest) + + add_test (munit_example ${CMAKE_BINARY_DIR}/bin/munit_example) +endif () + +install (FILES ${CMAKE_BINARY_DIR}/lib/pkgconfig/munit.pc + DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig) +install (FILES munit.h + DESTINATION ${CMAKE_INSTALL_PREFIX}/include) + +install (TARGETS munit LIBRARY) From 16fda4d273834bf9db4e7ca077f29243c19eaf7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8A=E3=82=8A?= <97130483+ori-d@users.noreply.github.com> Date: Sun, 28 May 2023 08:47:57 +0300 Subject: [PATCH 2/4] Add missing cmake/munit.pc.in --- cmake/munit.pc.in | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 cmake/munit.pc.in diff --git a/cmake/munit.pc.in b/cmake/munit.pc.in new file mode 100644 index 0000000..2c5aeb3 --- /dev/null +++ b/cmake/munit.pc.in @@ -0,0 +1,9 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: ${PROJECT_NAME} +Description: ${${PROJECT_NAME}_DESCRIPTION} +Version: ${${PROJECT_NAME}_VERSION} +Libs: -L${libdir} -lmunit +Cflags: -I${includedir} From 9e5a3b7c9736e0f085949277f9272cc56cd50903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8A=E3=82=8A?= <97130483+ori-d@users.noreply.github.com> Date: Sun, 28 May 2023 08:50:30 +0300 Subject: [PATCH 3/4] Remove @ONLY from configure_file --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d542030..de80d55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,8 +31,7 @@ set_target_properties (munit C_EXTENSIONS OFF) configure_file (cmake/munit.pc.in - ${CMAKE_BINARY_DIR}/lib/pkgconfig/munit.pc - @ONLY) + ${CMAKE_BINARY_DIR}/lib/pkgconfig/munit.pc) if (BUILD_EXAMPLE) add_executable (munit_example) From 0e87b76bc029a6c5a61b5bf23a5c9f3f723a77e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8A=E3=82=8A?= <97130483+ori-d@users.noreply.github.com> Date: Sun, 28 May 2023 08:52:09 +0300 Subject: [PATCH 4/4] Fixed BUILD_EXAMPLE with BUILD_TESTS --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index de80d55..7d797a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,7 @@ set_target_properties (munit configure_file (cmake/munit.pc.in ${CMAKE_BINARY_DIR}/lib/pkgconfig/munit.pc) -if (BUILD_EXAMPLE) +if (BUILD_TESTS) add_executable (munit_example) target_sources (munit_example