[GH-ISSUE #375] pkgconfig version is wrong when built with cmake #299

Closed
opened 2026-05-05 12:07:16 -06:00 by gitea-mirror · 4 comments
Owner

Originally created by @ephemer4l on GitHub (Jul 22, 2022).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/375

Originally assigned to: @jmcnamara on GitHub.

$ cat xlsxwriter.pc
prefix=/usr
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib

Name: libxlsxwriter
Description: A C library for creating Excel XLSX files
Version: 4
Cflags: -I${includedir}
Libs: -L${libdir} -lxlsxwriter -lz

somehow this regex in CMakeLists.txt evaluates to 4:

string(REGEX MATCH "LXW_VERSION .*\"\(.*\)\".*" _ ${ver})

built on gentoo with the ebuild:

# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit cmake plocale

DESCRIPTION="Libxlsxwriter is a C library for creating Excel XLSX files."
HOMEPAGE="https://libxlsxwriter.github.io/"
SRC_URI="https://github.com/jmcnamara/libxlsxwriter/archive/RELEASE_${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="BSD-2"
SLOT="0"
KEYWORDS="~amd64"
IUSE="openssl"
S="${WORKDIR}/${PN}-RELEASE_${PV}"

DEPEND="
	sys-libs/zlib[minizip]
"
RDEPEND="${DEPEND}"

src_configure() {
	DOUBLEFUNCTION=OFF
	for x in $(plocale_get_locales); do
		if ! [[ "${x}" =~ ^en* ]]; then
			#non-english locale detected; apply double function fix
			DOUBLEFUNCTION=ON
			break
		fi
	done
	local mycmakeargs=(
		-DCMAKE_BUILD_TYPE=Release
		-DUSE_OPENSSL_MD5="$(usex openssl ON OFF)"
		-DUSE_SYSTEM_MINIZIP="ON"
		-DBUILD_SHARED_LIBS="ON"
		-DUSE_DTOA_LIBRARY=${DOUBLEFUNCTION}
	)
	cmake_src_configure
}

src_install() {
	cmake_src_install
	dodoc CONTRIBUTING.md License.txt Readme.md Changes.txt
	dodoc -r docs examples
}
Originally created by @ephemer4l on GitHub (Jul 22, 2022). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/375 Originally assigned to: @jmcnamara on GitHub. ``` $ cat xlsxwriter.pc prefix=/usr exec_prefix=${prefix} includedir=${prefix}/include libdir=${exec_prefix}/lib Name: libxlsxwriter Description: A C library for creating Excel XLSX files Version: 4 Cflags: -I${includedir} Libs: -L${libdir} -lxlsxwriter -lz ``` somehow this regex in CMakeLists.txt evaluates to 4: ```cmake string(REGEX MATCH "LXW_VERSION .*\"\(.*\)\".*" _ ${ver}) ``` built on gentoo with the ebuild: ```ebuild # Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 inherit cmake plocale DESCRIPTION="Libxlsxwriter is a C library for creating Excel XLSX files." HOMEPAGE="https://libxlsxwriter.github.io/" SRC_URI="https://github.com/jmcnamara/libxlsxwriter/archive/RELEASE_${PV}.tar.gz -> ${P}.tar.gz" LICENSE="BSD-2" SLOT="0" KEYWORDS="~amd64" IUSE="openssl" S="${WORKDIR}/${PN}-RELEASE_${PV}" DEPEND=" sys-libs/zlib[minizip] " RDEPEND="${DEPEND}" src_configure() { DOUBLEFUNCTION=OFF for x in $(plocale_get_locales); do if ! [[ "${x}" =~ ^en* ]]; then #non-english locale detected; apply double function fix DOUBLEFUNCTION=ON break fi done local mycmakeargs=( -DCMAKE_BUILD_TYPE=Release -DUSE_OPENSSL_MD5="$(usex openssl ON OFF)" -DUSE_SYSTEM_MINIZIP="ON" -DBUILD_SHARED_LIBS="ON" -DUSE_DTOA_LIBRARY=${DOUBLEFUNCTION} ) cmake_src_configure } src_install() { cmake_src_install dodoc CONTRIBUTING.md License.txt Readme.md Changes.txt dodoc -r docs examples } ```
gitea-mirror 2026-05-05 12:07:16 -06:00
  • closed this issue
  • added the
    bug
    cmake
    labels
Author
Owner

@jmcnamara commented on GitHub (Jul 22, 2022):

Thanks. I can confirm it happens on macOS as well. I'll take a look.

<!-- gh-comment-id:1192062541 --> @jmcnamara commented on GitHub (Jul 22, 2022): Thanks. I can confirm it happens on macOS as well. I'll take a look.
Author
Owner

@jmcnamara commented on GitHub (Jul 22, 2022):

The greedy dot star strikes again.

The existing regex probably worked until the SOVERSION was added, which gave it an extra set of double quotes to match against. Anyway, I've pushed a fix to main that you can try.

<!-- gh-comment-id:1192079639 --> @jmcnamara commented on GitHub (Jul 22, 2022): The greedy dot star [strikes again](https://www.perlmonks.org/?node_id=24640). The existing regex probably worked until the SOVERSION was added, which gave it an extra set of double quotes to match against. Anyway, I've pushed a fix to main that you can try.
Author
Owner

@ephemer4l commented on GitHub (Jul 22, 2022):

I can confirm that this fix works. I'll add it to the package as a patch until next version is released. Thank you so much!

<!-- gh-comment-id:1192382492 --> @ephemer4l commented on GitHub (Jul 22, 2022): I can confirm that this fix works. I'll add it to the package as a patch until next version is released. Thank you so much!
Author
Owner

@jmcnamara commented on GitHub (Jul 22, 2022):

Thanks for the report and testing.

<!-- gh-comment-id:1192415148 --> @jmcnamara commented on GitHub (Jul 22, 2022): Thanks for the report and testing.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/libxlsxwriter#299
No description provided.