diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..7d797a0 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,55 @@ +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) + +if (BUILD_TESTS) + 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) 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}