File jsoncpp.spec of Package libjsoncpp

#
# spec file for package jsoncpp
#
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%define libname lib%{name}1
Name:           jsoncpp
Version:        1.6.5
Release:        0
Summary:        C++ library that allows manipulating with JSON
License:        MIT
Group:          Development/Libraries/C and C++
Url:            https://github.com/open-source-parsers/jsoncpp
#Source0:        https://github.com/open-source-parsers/%{name}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source0:        libjsoncpp_1.6.5.orig.tar.gz
BuildRequires:  cmake
BuildRequires:  gcc-c++
BuildRequires:  pkgconfig
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Patch0:         0005-optimize-werror.patch

%description
JSON is a lightweight data-interchange format. It can represent numbers,
strings, ordered sequences of values, and collections of name/value pairs.

JsonCpp is a C++ library that allows manipulating JSON values, including
serialization and deserialization to and from strings. It can also preserve
existing comment in unserialization/serialization steps, making it a convenient
format to store user input files.

%package devel
Summary:        Development files for %{name}
Group:          Development/Languages/C and C++
Requires:       %{libname} = %{version}

%description devel
JSON is a lightweight data-interchange format. It can represent numbers,
strings, ordered sequences of values, and collections of name/value pairs.

JsonCpp is a C++ library that allows manipulating JSON values, including
serialization and deserialization to and from strings. It can also preserve
existing comment in unserialization/serialization steps, making it a convenient
format to store user input files.

%package -n %{libname}
Summary:        Shared library for %{name}
Group:          System/Libraries

%description -n %{libname}
JSON is a lightweight data-interchange format. It can represent numbers,
strings, ordered sequences of values, and collections of name/value pairs.

JsonCpp is a C++ library that allows manipulating JSON values, including
serialization and deserialization to and from strings. It can also preserve
existing comment in unserialization/serialization steps, making it a convenient
format to store user input files.

%global debug_package %{nil}

%prep
%setup -q

%patch0 -p1

%build
CFLAGS="-O3 -fomit-frame-pointer -Wall -ffp-contract=off"
CXXFLAGS="-O3 -fomit-frame-pointer -Wall -ffp-contract=off"
LDFLAGS="-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now"
%ifarch x86_64
CFLAGS="-O3  -fomit-frame-pointer -mmmx -msse -msse2 -Wall -ffp-contract=off"
CXXFLAGS="-O3  -fomit-frame-pointer -mmmx -msse -msse2 -Wall -ffp-contract=off"
%endif
%ifarch %{ix86}
CFLAGS="-O3 -march=i686  -fomit-frame-pointer -mmmx -msse -msse2 -mno-sse4 -mno-sse3 -fpermissive -Wall -fexpensive-optimizations"
CXXFLAGS="-O3 -march=i686  -fomit-frame-pointer -mmmx -msse -msse2 -mno-sse4 -mno-sse3 -fpermissive -Wall -fexpensive-optimizations"
%endif
%ifarch aarch64
%define _lto_cflags %{nil}
%endif
%cmake -DJSONCPP_WITH_CMAKE_PACKAGE=ON -DCMAKE_CXX_FLAGS="$CFLAGS"  -DCMAKE_C_FLAGS="$CFLAGS"
# path needs to be exported otherwise unit tests will fail
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:%{_builddir}/%{name}-%{version}/build/src/lib_json
make %{?_smp_mflags}

%install
%make_install
rm -rf %{buildroot}%{_libdir}/lib%{name}.a

%post -n %{libname} -p /sbin/ldconfig
%postun -n %{libname} -p /sbin/ldconfig

%files -n %{libname}
%defattr(-,root,root)
%doc LICENSE
%{_libdir}/lib%{name}.so.*

%files devel
%defattr(-,root,root)
%doc AUTHORS LICENSE NEWS.txt README.md
%{_libdir}/pkgconfig/%{name}.pc
%{_libdir}/cmake/%{name}
%{_libdir}/lib%{name}.so
%{_includedir}/json/

%changelog
openSUSE Build Service is sponsored by