Skip to content

Commit 97d3c80

Browse files
committed
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 <obbardc@debian.org>
1 parent b8b37e3 commit 97d3c80

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,23 @@ endif()
6161
include_directories(
6262
${CMAKE_CURRENT_SOURCE_DIR}/include
6363
)
64+
65+
include(GNUInstallDirs)
66+
67+
install(TARGETS ${PROJECT_NAME}
68+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
69+
)
70+
71+
install(FILES include/CANvenient.h
72+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
73+
)
74+
75+
configure_file(
76+
${CMAKE_CURRENT_SOURCE_DIR}/canvenient.pc.in
77+
${CMAKE_CURRENT_BINARY_DIR}/canvenient.pc
78+
@ONLY
79+
)
80+
81+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/canvenient.pc
82+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
83+
)

canvenient.pc.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
prefix=@CMAKE_INSTALL_PREFIX@
2+
exec_prefix=${prefix}
3+
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
4+
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
5+
6+
Name: CANvenient
7+
Description: CAN library with multiple driver backends
8+
Version: @PROJECT_VERSION@
9+
Libs: -L${libdir} -lCANvenient
10+
Libs.private: -lsocketcan
11+
Cflags: -I${includedir}

0 commit comments

Comments
 (0)