Skip to content

Commit dfe6956

Browse files
committed
Configure and install pkg-config file
1 parent 261af36 commit dfe6956

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

CMakeLists.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,9 @@ target_compile_definitions(nvp
6666
# If we're on Linux, link against libbsd
6767
target_link_libraries(nvp PUBLIC $<$<PLATFORM_ID:Linux>:bsd>)
6868

69-
install(
70-
TARGETS nvp DESTINATION ${CMAKE_INSTALL_LIBDIR}
71-
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
72-
)
69+
# Generate pkg-config file
70+
set(DEST_DIR ${CMAKE_INSTALL_PREFIX})
71+
configure_file(nvp.pc.in bin/nvp.pc @ONLY)
7372

7473
function(build_test target)
7574
add_executable(${target} tests/${target}.c)
@@ -140,3 +139,13 @@ if(NVP_TEST)
140139
build_atf_test(nv_array_tests YES)
141140
endif()
142141
endif()
142+
143+
install(
144+
TARGETS nvp DESTINATION ${CMAKE_INSTALL_LIBDIR}
145+
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
146+
)
147+
148+
install(
149+
FILES ${CMAKE_CURRENT_BINARY_DIR}/bin/nvp.pc
150+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
151+
)

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,21 @@ A cross-platform userspace version of libnv ported from FreeBSD 12.
55
libnv is a library that facilitates the creation of lists of name-value pairs,
66
and the sending of those lists over sockets.
77

8-
To build with tests, run `cmake -DNVP_TEST=ON . && make`. To execute tests, run
9-
`make test`.
108

119
# Dependencies
1210

1311
- `libbsd`, which provides those BSD libc includes which differ from (or don't
1412
exist in) glibc.
1513
- `atf-c`, `atf-c++`, and `kyua` if you want to build and run the ATF tests.
1614

15+
16+
# Building
17+
18+
- The default install prefix is /usr/local . For a different prefix, set `-DCMAKE_INSTALL_PREFIX=/new/prefix`
19+
- To build with tests, set `-DNVP_TEST=ON`
20+
- To make, run `make`, to execute tests, run `make test` and to install, run `make install`
21+
22+
1723
# License
1824
```
1925
BSD 2-Clause License

nvp.pc.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
prefix=@DEST_DIR@
2+
exec_prefix=${prefix}
3+
libdir=${prefix}/lib
4+
includedir=${prefix}/include
5+
6+
Name: libnvp
7+
Description: A cross-platform userspace version of libnv ported from FreeBSD 12.
8+
Version: 1.0
9+
10+
Libs: -L${libdir} -lnvp
11+
Cflags: -I${includedir}

0 commit comments

Comments
 (0)