Skip to content

Commit 301b052

Browse files
authored
adding pkg support (#940)
1 parent 374eeaf commit 301b052

File tree

4 files changed

+65
-0
lines changed

4 files changed

+65
-0
lines changed

.github/workflows/pkg.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Debian pkg-config
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
pkg-config:
10+
runs-on: ubuntu-latest
11+
container:
12+
image: debian:12
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- name: Install dependencies
18+
run: |
19+
apt -y update
20+
apt -y --no-install-recommends install g++ cmake make pkg-config
21+
22+
- name: Build and install
23+
run: |
24+
cmake -B build
25+
cmake --build build
26+
cmake --install build
27+
28+
- name: Test pkg-config
29+
run: pkg-config --cflags --libs ada

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,18 @@ install(
163163
COMPONENT example_development
164164
)
165165

166+
167+
# pkg-config
168+
include(cmake/JoinPaths.cmake)
169+
join_paths(PKGCONFIG_INCLUDEDIR "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
170+
join_paths(PKGCONFIG_LIBDIR "\${prefix}" "${CMAKE_INSTALL_LIBDIR}")
171+
172+
configure_file("ada.pc.in" "ada.pc" @ONLY)
173+
install(
174+
FILES "${CMAKE_CURRENT_BINARY_DIR}/ada.pc"
175+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
176+
)
177+
166178
if(is_top_project)
167179
set(CPACK_PACKAGE_VENDOR "Ada Authors")
168180
set(CPACK_PACKAGE_CONTACT "[email protected]")

ada.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+
includedir=@PKGCONFIG_INCLUDEDIR@
3+
libdir=@PKGCONFIG_LIBDIR@
4+
5+
Name: @PROJECT_NAME@
6+
Description: @PROJECT_DESCRIPTION@
7+
URL: @PROJECT_HOMEPAGE_URL@
8+
Version: @PROJECT_VERSION@
9+
Cflags: -I${includedir} @PKGCONFIG_CFLAGS@
10+
Libs: -L${libdir} -l@PROJECT_NAME@
11+
@PKGCONFIG_LIBS_PRIVATE@

cmake/JoinPaths.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function(join_paths joined_path first_path_segment)
2+
set(temp_path "${first_path_segment}")
3+
foreach(current_segment IN LISTS ARGN)
4+
if(NOT ("${current_segment}" STREQUAL ""))
5+
if(IS_ABSOLUTE "${current_segment}")
6+
set(temp_path "${current_segment}")
7+
else()
8+
set(temp_path "${temp_path}/${current_segment}")
9+
endif()
10+
endif()
11+
endforeach()
12+
set(${joined_path} "${temp_path}" PARENT_SCOPE)
13+
endfunction()

0 commit comments

Comments
 (0)