From 9391353c2feec0773d8c1b187edf7de91a306ffa Mon Sep 17 00:00:00 2001 From: Funda Wang Date: Thu, 12 Dec 2024 18:14:43 +0800 Subject: [PATCH] adopt to new cmake macro --- jsoncpp.spec | 98 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 58 insertions(+), 40 deletions(-) diff --git a/jsoncpp.spec b/jsoncpp.spec index 0f81952..f9ea3e5 100644 --- a/jsoncpp.spec +++ b/jsoncpp.spec @@ -1,12 +1,28 @@ +%undefine __cmake_in_source_build + +# when libmajor changes, whole cmake toolchain will break +# rebuild cmake with bundled jsoncpp at first +%define libmajor 25 + +%bcond_with compatlib +%if %{with compatlib} +%define compatlib_version 1.9.5 +%define compatlib_libmajor 25 +%endif + Name: jsoncpp Version: 1.9.5 -Release: 5 +Release: 6 Summary: JSON C++ library License: Public Domain or MIT URL: https://github.com/open-source-parsers/jsoncpp Source0: https://github.com/open-source-parsers/jsoncpp/archive/%{version}/%{name}-%{version}.tar.gz -BuildRequires: gcc-c++ cmake >= 3.1 python3-devel - +%if %{with compatlib} +Source1: https://github.com/open-source-parsers/jsoncpp/archive/%{versino}/%{name}-%{compatlib_version}.tar.gz +%endif +BuildRequires: gcc-c++ +BuildRequires: cmake >= 3.8.0 +BuildRequires: python3-devel Patch0001: 0001-Parse-large-floats-as-infinity-1349-1353.patch Patch0002: 0001-Use-default-rather-than-hard-coded-8-for-maximum-agg.patch @@ -34,53 +50,53 @@ Obsoletes: jsoncpp-doc < %{version}-%{release} Help document for jsoncpp. %prep -%autosetup -p 1 -doxygen -s -u doc/doxyfile.in -sed -i -e 's!^DOT_FONTNAME.*=.*!DOT_FONTNAME =!g' doc/doxyfile.in +%autosetup -p1 -n %{name}-%{version} +%if %{with compatlib} +tar xf %{S:1} +%endif %build -install -d %{_vpath_builddir} -cd %{_vpath_builddir} %cmake -DBUILD_STATIC_LIBS=OFF -DJSONCPP_WITH_WARNING_AS_ERROR=OFF \ -DBUILD_OBJECT_LIBS:BOOL=OFF \ -DJSONCPP_WITH_PKGCONFIG_SUPPORT=ON -DJSONCPP_WITH_CMAKE_PACKAGE=ON \ - -DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF -DPYTHON_EXECUTABLE="%{__python3}" \ - .. -cd .. -%make_build -C %{_vpath_builddir} -cp -p %{_vpath_builddir}/version . + -DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF +%cmake_build + +cp -p %{__cmake_builddir}/version . %{__python3} doxybuild.py --with-dot --doxygen %{_bindir}/doxygen rm -f version -%install -%make_install -C %{_vpath_builddir} -mkdir -p %{buildroot}%{_docdir}/%{name} -cp README.md %{buildroot}%{_docdir}/%{name} -chmod 644 %{buildroot}%{_docdir}/%{name}/README.md -touch %{buildroot}%{_docdir}/%{name}//README.md -mkdir -p %{buildroot}%{_docdir}/%{name}/html -cp dist/doxygen/*/*.{html,png} %{buildroot}%{_docdir}/%{name}/html -chmod 644 %{buildroot}%{_docdir}/%{name}/html/*.{html,png} -touch %{buildroot}%{_docdir}/%{name}/html -hardlink -cfv %{buildroot}%{_docdir}/%{name} - -# When the .so file name changes during version upgrade, you need to copy the lower version of .so file -# cp -a %{_libdir}/libjsoncpp.so.* $RPM_BUILD_ROOT%{_libdir} +%if %{with compatlib} +pushd %{name}-%{compatlib_version} +%cmake -DBUILD_STATIC_LIBS=OFF -DJSONCPP_WITH_WARNING_AS_ERROR=OFF \ + -DBUILD_OBJECT_LIBS:BOOL=OFF \ + -DJSONCPP_WITH_PKGCONFIG_SUPPORT=ON -DJSONCPP_WITH_CMAKE_PACKAGE=ON \ + -DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF +%cmake_build +popd +%endif -%check -%make_build -C %{_vpath_builddir} jsoncpp_check +%install +%cmake_install -%post -/sbin/ldconfig +%if %{with compatlib} +pushd %{name}-%{compatlib_version}/%{__cmake_builddir}/lib +install -m755 lib%{name}.so.%{compatlib_version} lib%{name}.so.%{compatlib_libmajor} %{buildroot}%{_libdir}/ +popd +%endif -%postun -/sbin/ldconfig +%check +%ctest -j1 %files -%license AUTHORS LICENSE -%doc %dir %{_docdir}/%{name} -%exclude %{_docdir}/%{name}/html -%{_libdir}/lib%{name}.so.* +%license LICENSE +%doc README.md AUTHORS +%{_libdir}/lib%{name}.so.%{libmajor} +%{_libdir}/lib%{name}.so.%{version} +%if %{with compatlib} +%{_libdir}/lib%{name}.so.%{compatlib_libmajor} +%{_libdir}/lib%{name}.so.%{compatlib_version} +%endif %files devel %{_libdir}/lib%{name}.so @@ -89,11 +105,13 @@ hardlink -cfv %{buildroot}%{_docdir}/%{name} %{_libdir}/pkgconfig/%{name}.pc %files help -%doc %{_docdir}/%{name} -%doc %{_docdir}/%{name}/README.md - +%doc dist/doxygen/* %changelog +* Thu Dec 12 2024 Funda Wang - 1.9.5-6 +- adopt to new cmake macro +- add compat build option for upgrading + * Thu Nov 16 2023 liubo - 1.9.5-5 - Use default rather than hard-coded 8 for maximum aggregate member alignment -- Gitee