Improve compatibility with new CMake macro

Signed-off-by: Igor Raits <ignatenkobrain@fedoraproject.org>
This commit is contained in:
Igor Raits 2020-07-20 17:59:44 +02:00
parent 282b52e966
commit 5c6a93c686
No known key found for this signature in database
GPG Key ID: 115D5AB89C5C1E1E
1 changed files with 16 additions and 18 deletions

View File

@ -1,3 +1,5 @@
%undefine __cmake_in_source_build
# python3 is not available on RHEL <= 7
%if 0%{?fedora} || 0%{?rhel} > 7
%bcond_without python3
@ -68,44 +70,40 @@ code scan defect lists to find out added or fixed defects.
%build
make version.cc
mkdir csdiff_build
cd csdiff_build
%cmake .. -DBUILD_PYCSDIFF=OFF
make %{?_smp_mflags} VERBOSE=yes
%cmake -DBUILD_PYCSDIFF=OFF
%cmake_build
%if %{with python2}
mkdir ../csdiff_build_py2
cd ../csdiff_build_py2
%cmake .. -DPYTHON_EXECUTABLE=%{__python2}
make %{?_smp_mflags} VERBOSE=yes
%global _vpath_builddir %{_target_platform}-py2
%cmake -DPYTHON_EXECUTABLE=%{__python2}
%cmake_build
%undefine _vpath_builddir
%endif
%if %{with python3}
mkdir ../csdiff_build_py3
cd ../csdiff_build_py3
%cmake .. \
%global _vpath_builddir %{_target_platform}-py3
%cmake \
-DPYTHON_EXECUTABLE=%{__python3} \
-DBOOST_PYTHON_LIB_NAME=boost_python%{python3_version_nodots}
make %{?_smp_mflags} VERBOSE=yes pycsdiff
%cmake_build --target pycsdiff
%undefine _vpath_builddir
%endif
%install
%if %{with python2}
mkdir -vp %{buildroot}%{python2_sitearch}
install -vm0644 csdiff_build_py2/pycsdiff.so %{buildroot}%{python2_sitearch}
install -vm0644 %{_target_platform}-py2/pycsdiff.so %{buildroot}%{python2_sitearch}
%endif
%if %{with python3}
mkdir -vp %{buildroot}%{python3_sitearch}
install -vm0644 csdiff_build_py3/pycsdiff.so %{buildroot}%{python3_sitearch}
install -vm0644 %{_target_platform}-py3/pycsdiff.so %{buildroot}%{python3_sitearch}
%endif
cd csdiff_build
make install DESTDIR="$RPM_BUILD_ROOT"
%cmake_install
%check
cd csdiff_build
ctest %{?_smp_mflags} --output-on-failure
%ctest
%files
%{_bindir}/csdiff