File googletest.spec of Package googletest

%define realname googletest
%define srcext   tar.bz2

# turn off the generation of debuginfo rpm  (RH9) ??
%global debug_package %{nil}

%if 0%{?suse_version} < 1500
%define cxx11abi -D_GLIBCXX_USE_CXX11_ABI=0
%endif

# Common info
Name:          %{realname}
Version:       0
Release:       wiz%{?extraver:0.}1%{?dist}
License:       BSD-3-Clause
Group:         Development/Languages/C and C++
URL:           https://github.com/google/googletest
Summary:       Google Test

# Install-time parameters
Provides:      gtest = %{version}-%{release}
Obsoletes:     gtest < %{version}-%{release}

# Build-time parameters
BuildRequires: pkg-config cmake >= 2.8.8
BuildRequires: gcc-c++
%if 0%{?rhel} >= 8
BuildRequires: platform-python
%else
BuildRequires: python%{?suse_version:-base}
%endif
BuildRoot:     %{_tmppath}/%{name}-root
Source:        %{realname}-%{version}%{?extraver}.%{srcext}

%description
googletest is a testing framework developed by the Testing Technology team with
Google's specific requirements and constraints in mind.

%package devel
Group:         Development/Languages/C and C++
Summary:       Google Test
Provides:      libgmock-devel gmock-devel
Provides:      libgtest-devel gtest-devel
Provides:      gtest-devel = %{version}-%{release}
Obsoletes:     gtest-devel < %{version}-%{release}

%description devel
googletest is a testing framework developed by the Testing Technology team with
Google's specific requirements and constraints in mind.

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{version}%{?extraver}

%build
# Fix for RHEL/CentOS
_CFLAGS="%{optflags} -I%{_includedir}/ncurses -fPIC -Wno-unused-result"
_LDFLAGS="-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,now -Wl,-z,relro -pthread -fPIC"
%ifarch %ix86
_CFLAGS+=' -march=i686'
%endif
%{__mkdir} build
cd build
cmake .. \
 -DCMAKE_INSTALL_PREFIX=%{_prefix} \
 -DCMAKE_BUILD_TYPE=Release \
 -DCMAKE_C_FLAGS_RELEASE="$_CFLAGS" \
 -DCMAKE_CXX_FLAGS_RELEASE="$_CFLAGS %{?cxx11abi}" \
 -DCMAKE_EXE_LINKER_FLAGS_RELEASE="$_LDFLAGS" \
 -DCMAKE_MODULE_LINKER_FLAGS_RELEASE="$_LDFLAGS" \
 -DCMAKE_SHARED_LINKER_FLAGS_RELEASE="$_LDFLAGS -shared" \
 -DCMAKE_SKIP_RPATH=YES \
 -DCMAKE_VERBOSE_MAKEFILE=YES \
%if 0%{?rhel} >= 8
 -DPYTHON_EXECUTABLE=%{_libexecdir}/platform-python
%endif

%{__make} %{?_smp_mflags}

%install
%{__make} -C build install DESTDIR=%{buildroot}

%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}

# Development stuff
%files devel
%defattr(-,root,root)
%doc CONTRIBUTING.md LICENSE googletest/README.md
%{_libdir}/pkgconfig/*.pc
%dir %{_libdir}/cmake/GTest
%dir %{_libdir}/cmake
%{_libdir}/cmake/GTest/*.cmake
%{_includedir}/gmock/
%{_includedir}/gtest
%{_libdir}/*.a

%changelog
openSUSE Build Service is sponsored by