Skip to content

Commit bd02b11

Browse files
author
Will
committed
watcher,watcher-c: add pkg-config files
1 parent b03bdcf commit bd02b11

6 files changed

Lines changed: 86 additions & 16 deletions

File tree

CMakeLists.txt

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,24 @@ project(
1919
C
2020
)
2121

22+
include(CheckIPOSupported)
23+
include(FetchContent)
24+
include(GNUInstallDirs)
25+
2226
#
2327
# Options, Variable & Constants
2428
#
2529

26-
option(BUILD_LIB "Create targets for the watcher-c libraries" ON)
27-
option(BUILD_BIN "Create targets for the CLI binaries" ON)
28-
option(BUILD_HDR "Create targets for the headers (both the C++ single-header library and the watcher-c library header)" ON)
29-
option(BUILD_TESTING "Create targets for the test programs" OFF)
30-
option(BUILD_SAN "Mega-option to allow sanitizers" OFF)
31-
option(BUILD_ASAN "Create targets address-sanitized libraries and binaries" OFF)
32-
option(BUILD_MSAN "Create targets memory-sanitized libraries and binaries" OFF)
33-
option(BUILD_TSAN "Create targets thread-sanitized libraries and binaries" OFF)
34-
option(BUILD_UBSAN "Create targets undefined-behavior-sanitized libraries and binaries" OFF)
30+
option(BUILD_LIB "Create targets for the watcher-c libraries" ON)
31+
option(BUILD_BIN "Create targets for the CLI binaries" ON)
32+
option(BUILD_PKC_CONFIG "Create targets for the pkg-config files" ON)
33+
option(BUILD_HDR "Create targets for the headers (both the C++ single-header library and the watcher-c library header)" ON)
34+
option(BUILD_TESTING "Create targets for the test programs" OFF)
35+
option(BUILD_SAN "Mega-option to allow sanitizers" OFF)
36+
option(BUILD_ASAN "Create targets address-sanitized libraries and binaries" OFF)
37+
option(BUILD_MSAN "Create targets memory-sanitized libraries and binaries" OFF)
38+
option(BUILD_TSAN "Create targets thread-sanitized libraries and binaries" OFF)
39+
option(BUILD_UBSAN "Create targets undefined-behavior-sanitized libraries and binaries" OFF)
3540

3641
set(WTR_WATCHER_CXX_STD 17)
3742

@@ -181,9 +186,6 @@ function(wtr_add_bin_target
181186
elseif(IS_TEST)
182187
message(STATUS "${NAME}: Added (BUILD_TESTING=${BUILD_TESTING})")
183188
endif()
184-
include(CheckIPOSupported)
185-
include(FetchContent)
186-
include(GNUInstallDirs)
187189
add_executable("${NAME}" "${SRC_SET}")
188190
set_property(TARGET "${NAME}" PROPERTY CXX_STANDARD "${WTR_WATCHER_CXX_STD}")
189191
if(NOT WIN32 AND NOT IS_CC_MSVC AND NOT IS_CC_APPLECLANG)
@@ -241,7 +243,6 @@ function(wtr_add_lib_target NAME OUTPUT_NAME SRC_SET INC_SET LIB_TYPE)
241243
return()
242244
endif()
243245
message(STATUS "${NAME}: Added (BUILD_LIB=${BUILD_LIB})")
244-
include(GNUInstallDirs)
245246
add_library("${NAME}" "${LIB_TYPE}" "${SRC_SET}")
246247
target_include_directories("${NAME}" PRIVATE "${INC_SET}")
247248
set_property(TARGET "${NAME}" PROPERTY CXX_STANDARD "${WTR_WATCHER_CXX_STD}")
@@ -252,7 +253,7 @@ function(wtr_add_lib_target NAME OUTPUT_NAME SRC_SET INC_SET LIB_TYPE)
252253
target_compile_options("${NAME}" PRIVATE "${COMPILE_OPTIONS}")
253254
if("${NAME}" STREQUAL "watcher-c-shared" AND LINUX)
254255
message(STATUS "watcher-c-shared: Adding version script")
255-
target_link_options("${NAME}" PRIVATE "${LINK_OPTIONS};-Wl,--version-script=${CMAKE_SOURCE_DIR}/watcher-c/libwatcher-c.version")
256+
target_link_options("${NAME}" PRIVATE "${LINK_OPTIONS};-Wl,--version-script=${CMAKE_SOURCE_DIR}/watcher-c/watcher-c.version")
256257
else()
257258
target_link_options("${NAME}" PRIVATE "${LINK_OPTIONS}")
258259
endif()
@@ -274,7 +275,6 @@ function(wtr_add_hdr_target NAME HDR_SET)
274275
return()
275276
endif()
276277
message(STATUS "${NAME}: Added (BUILD_HDR=${BUILD_HDR})")
277-
include(GNUInstallDirs)
278278
add_library("${NAME}" INTERFACE "${HDR_SET}")
279279
target_include_directories("${NAME}" INTERFACE "${INCLPATH}")
280280
install(FILES "${HDR_SET}" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/wtr" COMPONENT "include")
@@ -449,3 +449,24 @@ wtr_add_bin_target(
449449
""
450450
)
451451

452+
if(BUILD_HDR AND BUILD_PKC_CONFIG)
453+
message(STATUS "Generating watcher.h (BUILD_HDR=${BUILD_HDR}, BUILD_PKC_CONFIG=${BUILD_PKC_CONFIG})")
454+
set(PC_WATCHER_LIBS_PRIVATE "${LINK_LIBRARIES}")
455+
set(PC_WATCHER_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
456+
set(PC_WATCHER_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/wtr")
457+
configure_file("watcher.pc.in" "${CMAKE_BINARY_DIR}/watcher.pc" @ONLY)
458+
install(FILES "${CMAKE_BINARY_DIR}/watcher.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" COMPONENT "include")
459+
else()
460+
message(STATUS "Skipping watcher.pc generation (BUILD_HDR=${BUILD_HDR}, BUILD_PKC_CONFIG=${BUILD_PKC_CONFIG})")
461+
endif()
462+
463+
if(BUILD_LIB AND BUILD_PKC_CONFIG)
464+
message(STATUS "Generating watcher-c.pc (BUILD_LIB=${BUILD_LIB}, BUILD_PKC_CONFIG=${BUILD_PKC_CONFIG})")
465+
set(PC_LIBWATCHER_C_LIBS_PRIVATE "${LINK_LIBRARIES}")
466+
set(PC_LIBWATCHER_C_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
467+
set(PC_LIBWATCHER_C_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/wtr")
468+
configure_file("watcher-c/watcher-c.pc.in" "${CMAKE_BINARY_DIR}/watcher-c.pc" @ONLY)
469+
install(FILES "${CMAKE_BINARY_DIR}/watcher-c.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" COMPONENT "include")
470+
else()
471+
message(STATUS "Skipping watcher-c.pc generation (BUILD_LIB=${BUILD_LIB}, BUILD_PKC_CONFIG=${BUILD_PKC_CONFIG})")
472+
endif()

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.13.7
4+
5+
Added `pkg-config` files for `watcher` and `watcher-c`.
6+
37
## 0.13.6
48

59
Special thanks to @DanielCodesphere and @jordan-woyak for their important contributions in this release.

watcher-c/meson.build

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,22 @@ watcher_hpp_dep = declare_dependency(sources : watcher_hpp)
1414

1515
libwatcher_c_name = 'watcher-c'
1616

17+
libwatcher_c_pc_cfgdata = configuration_data()
18+
libwatcher_c_pc_cfgdata.set('PC_LIBWATCHER_C_PREFIX', get_option('prefix'))
19+
libwatcher_c_pc_cfgdata.set('PC_LIBWATCHER_C_LIBDIR', join_paths(get_option('prefix'), get_option('libdir')))
20+
libwatcher_c_pc_cfgdata.set('PC_LIBWATCHER_C_INCLUDEDIR', join_paths(get_option('prefix'), get_option('includedir')))
21+
libwatcher_c_pc_cfgdata.set('PROJECT_DESCRIPTION', 'watcher: a filesystem watcher')
22+
libwatcher_c_pc_cfgdata.set('PROJECT_HOMEPAGE_URL', 'github.com/e-dant/watcher')
23+
libwatcher_c_pc_cfgdata.set('PROJECT_VERSION', meson.project_version())
24+
1725
if target_machine.system() == 'darwin'
1826
libwatcher_c_deps = [dependency('CoreServices'), dependency('CoreFoundation'), watcher_hpp_dep]
27+
libwatcher_c_pc_cfgdata.set('PC_LIBWATCHER_C_LIBS_PRIVATE', '-framework CoreFoundation -framework CoreServices')
1928
else
2029
libwatcher_c_deps = [dependency('threads'), watcher_hpp_dep]
30+
libwatcher_c_pc_cfgdata.set('PC_LIBWATCHER_C_LIBS_PRIVATE', '-lpthread')
2131
endif
2232

23-
2433
libwatcher_c = library(
2534
libwatcher_c_name,
2635
['src/watcher-c.cpp'],
@@ -32,6 +41,14 @@ libwatcher_c = library(
3241
version : meson.project_version(),
3342
)
3443

44+
libwatcher_c_pc = configure_file(
45+
input : 'watcher-c.pc.in',
46+
output : 'watcher-c.pc',
47+
configuration : libwatcher_c_pc_cfgdata,
48+
install : true,
49+
install_dir : join_paths(get_option('libdir'), 'pkgconfig')
50+
)
51+
3552
test_libwatcher_c = executable(
3653
'test-watcher-c',
3754
['src/test-watcher-c.c'],

watcher-c/watcher-c.pc.in

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
prefix=@PC_LIBWATCHER_C_PREFIX@
2+
exec_prefix=${prefix}
3+
libdir=@PC_LIBWATCHER_C_LIBDIR@
4+
includedir=@PC_LIBWATCHER_C_INCLUDEDIR@
5+
6+
Name: libwatcher-c
7+
Description: @PROJECT_DESCRIPTION@
8+
URL: @PROJECT_HOMEPAGE_URL@
9+
Version: @PROJECT_VERSION@
10+
Requires:
11+
Conflicts:
12+
Libs: -L${libdir} -lwatcher-c
13+
Libs.private: @PC_LIBWATCHER_C_LIBS_PRIVATE@
14+
Cflags: -I${includedir}

watcher.pc.in

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
prefix=@PC_WATCHER_PREFIX@
2+
exec_prefix=${prefix}
3+
libdir=@PC_WATCHER_LIBDIR@
4+
includedir=@PC_WATCHER_INCLUDEDIR@
5+
6+
Name: watcher
7+
Description: @PROJECT_DESCRIPTION@
8+
URL: @PROJECT_HOMEPAGE_URL@
9+
Version: @PROJECT_VERSION@
10+
Requires:
11+
Conflicts:
12+
Libs:
13+
Libs.private: @PC_WATCHER_LIBS_PRIVATE@
14+
Cflags: -I${includedir}

0 commit comments

Comments
 (0)