From 85ff28360bb6df257e39e742abb5d7bfe658a8df Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Mon, 9 Oct 2023 17:20:18 -0700 Subject: [PATCH] add library packaging --- CMakeLists.txt | 17 ++++++++++++++++- CMakePack.txt | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 CMakePack.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d29777..bb281d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,8 @@ cmake_minimum_required(VERSION 3.25) -project(klib CXX) +project(klib LANGUAGES CXX VERSION 0.0.1) set(CMAKE_CXX_STANDARD 14) + if(MSVC) add_compile_options("/W4" "$<$:/O2>") else() @@ -29,12 +30,26 @@ install(TARGETS klib LIBRARY DESTINATION ${PREFIX}/lib) install(FILES ${HEADER_FILES} DESTINATION include/klib) install(FILES klibConfig.cmake DESTINATION share/klib/cmake) +include(CTest) +enable_testing() + add_executable(tlv_test tlvTest.cc) target_link_libraries(tlv_test klib) +add_test(tlvTest tlv_test) add_executable(dictionary_test dictionaryTest.cc) target_link_libraries(dictionary_test klib) +add_test(dictionaryTest dictionary_test) add_executable(buffer_test bufferTest.cc) target_link_libraries(buffer_test klib) +add_test(bufferTest buffer_test) +include(CMakePack.txt) + +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + klibConfig.cmake + VERSION ${PACKAGE_VERSION} + COMPATIBILITY AnyNewerVersion +) \ No newline at end of file diff --git a/CMakePack.txt b/CMakePack.txt new file mode 100644 index 0000000..b7fefb2 --- /dev/null +++ b/CMakePack.txt @@ -0,0 +1,35 @@ +# Packaging support +include(InstallRequiredSystemLibraries) + +set(CPACK_PACKAGE_VENDOR "Shimmering Clarity") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Common C++ functionality.") +set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) +set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) + + +# Debian settings +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "K. Isom") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Shimmering Clarity C++ library") +set(CPACK_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION}) +set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc++1 (>= 3.7.0-1)") +set(CPACK_DEBIAN_PACKAGE_SECTION devel) + +if(LINUX) +set(CPACK_GENERATOR "DEB;STGZ;TGZ") +elseif(APPLE) +set(CPACK_GENERATOR "PACKAGEMAKER") +elseif(MSVC OR MSYS OR MINGW) +set(CPACK_GENERATOR "NSIS;ZIP") +else() +set(CPACK_GENERATOR "ZIP") +endif() + +set(CPACK_SOURCE_GENERATOR "TGZ;ZIP") + +set(CPACK_SOURCE_IGNORE_FILES + /.git + /dist + /.*build.*) + +include (CPack)