Skip to content

Commit 3a975c6

Browse files
committed
build: fix pkg-config requires
Issue #471
1 parent ea6da0d commit 3a975c6

3 files changed

Lines changed: 29 additions & 4 deletions

File tree

CMakeLists.txt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,28 @@ if(NOT MSVC)
211211
find_package(PkgConfig)
212212
endif()
213213

214-
file(READ "include/xlsxwriter.h" ver)
214+
# Set some variables for the xlsxwriter.pc file and the .so version.
215+
# ------------------------------------------------------------------
216+
set(PREFIX ${CMAKE_INSTALL_PREFIX})
215217

218+
file(READ "include/xlsxwriter.h" ver)
216219
string(REGEX MATCH "LXW_VERSION \"([^\"]+)\"" _ ${ver})
217220
set(VERSION ${CMAKE_MATCH_1})
218221
string(REGEX MATCH "LXW_SOVERSION \"([^\"]+)\"" _ ${ver})
219222
set(SOVERSION ${CMAKE_MATCH_1})
220-
set(PREFIX ${CMAKE_INSTALL_PREFIX})
221223

224+
set(ENABLED_OPTIONS "zlib")
225+
if(USE_SYSTEM_MINIZIP)
226+
string(APPEND ENABLED_OPTIONS " minizip")
227+
endif()
228+
if(USE_OPENSSL_MD5)
229+
string(APPEND ENABLED_OPTIONS " libcrypto")
230+
endif()
231+
232+
# Expand out the xlsxwriter.pc file.
222233
configure_file(dev/release/pkg-config.txt xlsxwriter.pc @ONLY)
223234

235+
224236
# INCLUDES
225237
# --------
226238
enable_language(CXX)

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ PYTESTFILES ?= test
2121
VERSION = $(shell sed -n -e 's/.*LXW_VERSION \"\(.*\)\"/\1/p' include/xlsxwriter.h)
2222
SOVERSION = $(shell sed -n -e 's/.*LXW_SOVERSION \"\(.*\)\"/\1/p' include/xlsxwriter.h)
2323

24+
ENABLED_OPTIONS = zlib
25+
ifdef USE_SYSTEM_MINIZIP
26+
ENABLED_OPTIONS += minizip
27+
endif
28+
ifdef USE_OPENSSL_MD5
29+
ENABLED_OPTIONS += libcrypto
30+
endif
31+
2432
.PHONY: docs tags examples third_party
2533

2634
# Build libxlsxwriter.
@@ -164,7 +172,11 @@ install: all
164172
$(Q)mkdir -p $(DESTDIR)$(PREFIX)/lib
165173
$(Q)cp -R lib/* $(DESTDIR)$(PREFIX)/lib
166174
$(Q)mkdir -p $(DESTDIR)$(PREFIX)/lib/pkgconfig
167-
$(Q)sed -e 's|@PREFIX@|$(PREFIX)|g' -e 's|@VERSION@|$(VERSION)|g' dev/release/pkg-config.txt > $(DESTDIR)$(PREFIX)/lib/pkgconfig/xlsxwriter.pc
175+
$(Q)sed -e 's|@PREFIX@|$(PREFIX)|g' \
176+
-e 's|@VERSION@|$(VERSION)|g' \
177+
-e 's|@ENABLED_OPTIONS@|$(ENABLED_OPTIONS)|g' \
178+
dev/release/pkg-config.txt \
179+
> $(DESTDIR)$(PREFIX)/lib/pkgconfig/xlsxwriter.pc
168180

169181
# Simpler uninstall.
170182
uninstall:

dev/release/pkg-config.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ Name: libxlsxwriter
77
Description: A C library for creating Excel XLSX files
88
Version: @VERSION@
99
Cflags: -I${includedir}
10-
Libs: -L${libdir} -lxlsxwriter -lz
10+
Libs: -L${libdir} -lxlsxwriter
11+
Requires.private: @ENABLED_OPTIONS@

0 commit comments

Comments
 (0)