From 97d3c80b3cb40db6d97d830b87d9c6a09584fb02 Mon Sep 17 00:00:00 2001 From: Christopher Obbard Date: Sat, 4 Apr 2026 08:10:54 +0100 Subject: [PATCH] cmake: add install targets and pkg-config support Add CMake install() directives for the shared library and public header and introduce a canvenient.pc.in template to generate a pkg-config file at build time. The pkg-config file is installed to the multiarch pkgconfig directory. Signed-off-by: Christopher Obbard --- CMakeLists.txt | 20 ++++++++++++++++++++ canvenient.pc.in | 11 +++++++++++ 2 files changed, 31 insertions(+) create mode 100644 canvenient.pc.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 3830a35..ca21ecb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,3 +61,23 @@ endif() include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include ) + +include(GNUInstallDirs) + +install(TARGETS ${PROJECT_NAME} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +install(FILES include/CANvenient.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/canvenient.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/canvenient.pc + @ONLY +) + +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/canvenient.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig +) diff --git a/canvenient.pc.in b/canvenient.pc.in new file mode 100644 index 0000000..c45a896 --- /dev/null +++ b/canvenient.pc.in @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ + +Name: CANvenient +Description: CAN library with multiple driver backends +Version: @PROJECT_VERSION@ +Libs: -L${libdir} -lCANvenient +Libs.private: -lsocketcan +Cflags: -I${includedir}