jmcnamara / libxlsxwriter

A C library for creating Excel XLSX files.
https://libxlsxwriter.github.io
Other
1.49k stars 332 forks source link

pkgconfig version is wrong when built with cmake #375

Closed ephemer4l closed 2 years ago

ephemer4l commented 2 years ago
$ 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
}
jmcnamara commented 2 years ago

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

jmcnamara commented 2 years ago

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.

ephemer4l commented 2 years ago

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!

jmcnamara commented 2 years ago

Thanks for the report and testing.