dev-cpp/cpp-hocon: fix build with glibc-2.34, conditionally build tests

Closes: https://bugs.gentoo.org/823419
Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Sam James
2021-12-29 00:12:25 +00:00
parent 7571d22a49
commit 28d0fbda2f
2 changed files with 91 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
inherit cmake prefix
DESCRIPTION="Provides C++ support for the HOCON configuration file format"
HOMEPAGE="https://github.com/puppetlabs/cpp-hocon"
SRC_URI="https://github.com/puppetlabs/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz"
LICENSE="Apache-2.0"
SLOT="0/${PV}"
KEYWORDS="~amd64 ~arm ~ppc64 ~x86"
IUSE="debug test"
RESTRICT="!test? ( test )"
RDEPEND="
>=dev-libs/boost-1.54:=[nls]
>=dev-libs/leatherman-0.9.3:=
"
DEPEND="${DEPEND}
test? ( dev-cpp/catch:1 )"
#PATCHES=( "${FILESDIR}"/${PN}-0.2.1-cmake.patch )
PATCHES=( "${FILESDIR}"/${PN}-0.3.0-use-system-catch.patch )
src_prepare() {
cmake_src_prepare
eprefixify lib/tests/CMakeLists.txt
}
src_configure() {
local mycmakeargs=(
-DBUILD_TESTING=$(usex test)
)
cmake_src_configure
}

View File

@@ -0,0 +1,51 @@
https://bugs.gentoo.org/823419
Wanted to make this "proper" but Catch2 lacks a pkgconfig file (or a CMake one)
and it's easier to just do this for now.
Based on patch version of sed commands from upstream bug
(https://github.com/puppetlabs/cpp-hocon/issues/132) and
Fedora (https://src.fedoraproject.org/rpms/cpp-hocon/blob/rawhide/f/cpp-hocon.spec#_76).
Makes tests conditional too.
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,12 +16,16 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif()
-enable_testing()
-
# Leatherman setup
-set(LEATHERMAN_COMPONENTS locale catch nowide util)
+set(LEATHERMAN_COMPONENTS locale nowide util)
find_package(Leatherman REQUIRED COMPONENTS ${LEATHERMAN_COMPONENTS})
+option(BUILD_TESTING "Build test suite (needs Catch)" ON)
+
+if(BUILD_TESTING)
+ enable_testing()
+endif()
+
## Before we find any packages, we want to pull in the common leatherman options, as they can affect commonly-used packages.
include(options)
## Pull in common cflags setting from leatherman. Don't override CMAKE_CXX_FLAGS at the project root to avoid impacting 3rd party code.
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -91,4 +91,6 @@ symbol_exports(lib${PROJECT_NAME} "${CMAKE_CURRENT_LIST_DIR}/inc/hocon/export.h"
leatherman_install(lib${PROJECT_NAME})
install(DIRECTORY inc/hocon DESTINATION include)
-add_subdirectory(tests)
+if (BUILD_TESTING)
+ add_subdirectory(tests)
+endif()
--- a/lib/tests/CMakeLists.txt
+++ b/lib/tests/CMakeLists.txt
@@ -1,5 +1,5 @@
# Setup compiling the test executable. C++ compile flags are inherited from the parent directory.
-include_directories(${LEATHERMAN_CATCH_INCLUDE})
+include_directories(@GENTOO_PORTAGE_EPREFIX@/usr/include/catch)
set(TEST_CASES
concatenation_test.cc