Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit 3f37e65

Browse files
committed
Fix pkg-config generation
this fixes #25
1 parent 6fca852 commit 3f37e65

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

CMakeLists.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ add_subdirectory(tests)
99
# set up versioning.
1010
set(BUILD_MAJOR "1")
1111
set(BUILD_MINOR "0")
12-
set(BUILD_VERSION "13")
12+
set(BUILD_VERSION "14")
1313
set(BUILD_VERSION ${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_VERSION})
1414

1515
set(CMAKE_C_STANDARD 11)
@@ -40,5 +40,18 @@ install(
4040
DESTINATION ${BASEENCODE_INC_DIR}
4141
)
4242

43+
# Allow adding prefix if CMAKE_INSTALL_INCLUDEDIR not absolute.
44+
if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
45+
set(PKGCONFIG_TARGET_INCLUDES "${CMAKE_INSTALL_INCLUDEDIR}")
46+
else()
47+
set(PKGCONFIG_TARGET_INCLUDES "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
48+
endif()
49+
# Allow adding prefix if CMAKE_INSTALL_LIBDIR not absolute.
50+
if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
51+
set(PKGCONFIG_TARGET_LIBS "${CMAKE_INSTALL_LIBDIR}")
52+
else()
53+
set(PKGCONFIG_TARGET_LIBS "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
54+
endif()
55+
4356
configure_file("baseencode.pc.in" "baseencode.pc" @ONLY)
4457
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/baseencode.pc" DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig/)

baseencode.pc.in

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
prefix=@CMAKE_INSTALL_PREFIX@
2+
exec_prefix=${prefix}
3+
libdir=@PKGCONFIG_TARGET_LIBS@
4+
includedir=@PKGCONFIG_TARGET_INCLUDES@
5+
16
Name: libbaseencode
27
Description: C library for encoding and decoding data using base32 or base64
38
Version: @BUILD_VERSION@
4-
Libs: -L@CMAKE_INSTALL_PREFIX@/@BASEENCODE_LIB_DIR@ -lbaseencode
5-
Cflags: -I@CMAKE_INSTALL_PREFIX@/@BASEENCODE_INC_DIR@
9+
URL: https://github.com/paolostivanin/libbaseencode
10+
Libs: -L${libdir} -lbaseencode
11+
Cflags: -I${includedir}

0 commit comments

Comments
 (0)