commit:     75d2153d06a3e3a5a3f2186effd13f994968fb90
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Jul 26 03:06:10 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Jul 26 03:06:10 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=75d2153d

dev-libs/unittest++: workaround broken .pc file

The 'Version' field of unittest++'s .pc file is blank for two reasons:
1) CMakeLists.txt doesn't define a version, and
2) if it did define a version, it doesn't try to substitute it

A new, yet-unpackaged version of app-text/enchant does a version check
on the unittest++ version which falls over on it being blank.

Bug: https://bugs.gentoo.org/863974
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../files/unittest++-2.0.0-fix-pc-version.patch    | 37 ++++++++++++++
 dev-libs/unittest++/unittest++-2.0.0-r4.ebuild     | 59 ++++++++++++++++++++++
 2 files changed, 96 insertions(+)

diff --git a/dev-libs/unittest++/files/unittest++-2.0.0-fix-pc-version.patch 
b/dev-libs/unittest++/files/unittest++-2.0.0-fix-pc-version.patch
new file mode 100644
index 000000000000..f8890db4ef00
--- /dev/null
+++ b/dev-libs/unittest++/files/unittest++-2.0.0-fix-pc-version.patch
@@ -0,0 +1,37 @@
+https://bugs.gentoo.org/863974
+https://github.com/unittest-cpp/unittest-cpp/pull/188
+https://github.com/msys2/MINGW-packages/issues/17297
+
+From 91790b98e03654c72b0783cf8fbc66c5f56892f5 Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <[email protected]>
+Date: Mon, 18 Dec 2023 19:05:55 +0000
+Subject: [PATCH] CMakeLists.txt: fix PACKAGE_VERSION substitution in .pc file
+
+Before the change project built using `cmake` had Version field empty:
+
+    Version:
+
+After the change version is set as expected:
+
+    Version: 2.1.0
+
+Noticed as as a build failure of `echant-2.6.4` which failed to find the
+package using `pkg-config --exists --print-errors "UnitTest++ >= 1.6"`
+expression.
+---
+ CMakeLists.txt | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index b4c75c9..10ecf60 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -135,6 +135,7 @@ set(prefix      ${CMAKE_INSTALL_PREFIX})
+ set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin)
+ set(libdir      ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
+ set(includedir  ${CMAKE_INSTALL_PREFIX}/include/UnitTest++)
++set(PACKAGE_VERSION ${CMAKE_PROJECT_VERSION})
+ configure_file("UnitTest++.pc.in" "UnitTest++.pc" @ONLY)
+ if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
+     set(pkgconfdir  ${CMAKE_INSTALL_PREFIX}/libdata/pkgconfig)
+

diff --git a/dev-libs/unittest++/unittest++-2.0.0-r4.ebuild 
b/dev-libs/unittest++/unittest++-2.0.0-r4.ebuild
new file mode 100644
index 000000000000..1d9f33f228c4
--- /dev/null
+++ b/dev-libs/unittest++/unittest++-2.0.0-r4.ebuild
@@ -0,0 +1,59 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit cmake dot-a
+
+MY_PN="unittest-cpp"
+MY_P="${MY_PN}-${PV}"
+
+DESCRIPTION="A lightweight unit testing framework for C++"
+HOMEPAGE="https://unittest-cpp.github.io/";
+SRC_URI="https://github.com/${MY_PN}/${MY_PN}/archive/v${PV}.tar.gz -> 
${P}.tar.gz"
+S="${WORKDIR}/${MY_P}"
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~ppc ~ppc64 ~riscv ~s390 
~sparc ~x86"
+IUSE="test"
+RESTRICT="!test? ( test )"
+
+PATCHES=(
+       # 
https://github.com/unittest-cpp/unittest-cpp/commit/2423fcac7668aa9c331a2dcf024c3ca06742942d
+       "${FILESDIR}"/${P}-fix-tests-with-clang.patch
+
+       "${FILESDIR}"/${P}-cmake-fix-pkgconfig-dir-path-on-FreeBSD.patch
+       "${FILESDIR}"/${P}-Add-support-for-LIB_SUFFIX.patch
+       "${FILESDIR}"/${P}-cmake4.patch
+)
+
+src_prepare() {
+       cmake_src_prepare
+
+       # https://github.com/unittest-cpp/unittest-cpp/pull/163
+       sed -i '/run unit tests as post build step/,/Running unit tests/d' \
+               CMakeLists.txt || die
+}
+
+src_configure() {
+       lto-guarantee-fat
+
+       local mycmakeargs=(
+               # Don't build with -Werror: https://bugs.gentoo.org/747583
+               -DUTPP_AMPLIFY_WARNINGS=OFF
+               -DUTPP_INCLUDE_TESTS_IN_BUILD=$(usex test)
+               # Workaround for bug #863974 and broken .pc file
+               -DPACKAGE_VERSION=${PV}
+       )
+       cmake_src_configure
+}
+
+src_test() {
+       "${BUILD_DIR}/TestUnitTest++" || die "Tests failed"
+}
+
+src_install() {
+       cmake_src_install
+       strip-lto-bytecode
+}

Reply via email to