Install .pc file

This commit is contained in:
Xavier Del Campo Romero 2023-10-16 00:13:24 +02:00
parent d0d843b704
commit ef14ee964a
Signed by: xavi
GPG Key ID: 84FF3612A9BF43F2
3 changed files with 25 additions and 1 deletions

View File

@ -17,3 +17,9 @@ add_library(${PROJECT_NAME} STATIC "dynstr.c")
target_include_directories(${PROJECT_NAME} PUBLIC "include")
install(TARGETS ${PROJECT_NAME})
install(DIRECTORY include/ TYPE INCLUDE)
file(READ ${CMAKE_CURRENT_LIST_DIR}/dynstr.pc dynstr_pc)
string(REPLACE /usr/local ${CMAKE_INSTALL_PREFIX} dynstr_repl_pc ${dynstr_pc})
file(WRITE ${CMAKE_BINARY_DIR}/dynstr.pc ${dynstr_repl_pc})
include(GNUInstallDirs)
install(FILES ${CMAKE_BINARY_DIR}/dynstr.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

View File

@ -15,6 +15,8 @@
.POSIX:
PREFIX = /usr/local
DST = $(PREFIX)/lib
PC_DST = $(DST)/pkgconfig
PROJECT = libdynstr.a
CFLAGS = -Iinclude
DEPS = \
@ -22,7 +24,7 @@ DEPS = \
all: $(PROJECT)
install: $(PROJECT)
install: $(PROJECT) $(PC_DST)/dynstr.pc
mkdir -p $(PREFIX)/include
cp include/dynstr.h $(PREFIX)/include
chmod 0644 $(PREFIX)/include/dynstr.h
@ -35,3 +37,8 @@ clean:
$(PROJECT): $(DEPS)
$(AR) $(ARFLAGS) $@ $(DEPS)
$(PC_DST)/dynstr.pc: dynstr.pc
mkdir -p $(PC_DST)
sed -e 's,/usr/local,$(PREFIX),' $< > $@
chmod 0644 $@

11
dynstr.pc Normal file
View File

@ -0,0 +1,11 @@
prefix=/usr/local
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib
Name: dynstr
Url: https://gitea.privatedns.org/xavi/dynstr
Description: Minimal library that provides dynamic strings using plain C99.
Version: 0.1.0
Cflags: -I${includedir}
Libs: -L${libdir} -ldynstr