2013-08-16 11:35:44 +02:00
|
|
|
#
|
|
|
|
# Macros for cmake
|
|
|
|
#
|
|
|
|
%__cmake %{_bindir}/cmake
|
2014-08-18 10:21:42 +02:00
|
|
|
%__ctest %{_bindir}/ctest
|
2016-03-08 08:29:07 +01:00
|
|
|
%__builddir build
|
2016-08-26 12:34:52 +02:00
|
|
|
%__builder %__make
|
2016-09-26 13:02:24 +02:00
|
|
|
%__sourcedir .
|
2013-08-16 11:35:44 +02:00
|
|
|
|
2023-04-21 14:32:35 +02:00
|
|
|
%__cmake_make_prefix_relative() %{lua:print((string.gsub((rpm.expand("%1")), ((rpm.expand("%{_prefix}")) .. "/"), "", 1)))}
|
|
|
|
%__cmake_make_root_relative() %{lua:print((string.gsub((rpm.expand("%1")), "/", "", 1)))}
|
2023-04-13 13:28:17 +02:00
|
|
|
|
2013-08-16 11:35:44 +02:00
|
|
|
%cmake \
|
2022-07-03 14:07:34 +02:00
|
|
|
find %__sourcedir -type f -name CMakeLists.txt \\\
|
2014-07-02 10:57:25 +02:00
|
|
|
-exec sed -i -re '/^[[:blank:]]*[sS][eE][tT][[:blank:]]*\\\([[:blank:]]*(CMAKE_BUILD_TYPE|CMAKE_COLOR_MAKEFILE|CMAKE_INSTALL_PREFIX|CMAKE_VERBOSE_MAKEFILE).*\\\)/{s/^/#IGNORE /}' {} + \
|
2016-03-08 08:29:07 +01:00
|
|
|
mkdir -p %__builddir \
|
|
|
|
cd %__builddir \
|
2016-09-26 13:02:24 +02:00
|
|
|
%__cmake $OLDPWD/%__sourcedir \\\
|
2016-08-26 12:34:52 +02:00
|
|
|
%if "%__builder" == "%__make" \
|
|
|
|
-G"Unix Makefiles" \\\
|
|
|
|
%else \
|
|
|
|
-GNinja \\\
|
|
|
|
%endif \
|
2013-08-16 11:35:44 +02:00
|
|
|
-DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \\\
|
2023-04-13 13:28:17 +02:00
|
|
|
-DCMAKE_INSTALL_BINDIR:PATH=%{__cmake_make_prefix_relative %{_bindir}} \\\
|
|
|
|
-DCMAKE_INSTALL_SBINDIR:PATH=%{__cmake_make_prefix_relative %{_sbindir}} \\\
|
|
|
|
-DCMAKE_INSTALL_LIBEXECDIR:PATH=%{__cmake_make_prefix_relative %{_libexecdir}} \\\
|
|
|
|
-DCMAKE_INSTALL_SYSCONFDIR:PATH=%{__cmake_make_root_relative %{_sysconfdir}} \\\
|
|
|
|
-DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=%{_sharedstatedir} \\\
|
|
|
|
-DCMAKE_INSTALL_LOCALSTATEDIR:PATH=%{__cmake_make_root_relative %{_localstatedir}} \\\
|
|
|
|
-DCMAKE_INSTALL_RUNSTATEDIR:PATH=%{__cmake_make_root_relative %{_rundir}} \\\
|
|
|
|
-DCMAKE_INSTALL_LIBDIR:PATH=%{__cmake_make_prefix_relative %{_libdir}} \\\
|
|
|
|
-DCMAKE_INSTALL_INCLUDEDIR:PATH=%{__cmake_make_prefix_relative %{_includedir}} \\\
|
|
|
|
-DCMAKE_INSTALL_DATAROOTDIR:PATH=%{__cmake_make_prefix_relative %{_datadir}} \\\
|
2023-04-24 11:18:48 +02:00
|
|
|
-DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \\\
|
|
|
|
-DLIB_INSTALL_DIR:PATH=%{_libdir} \\\
|
|
|
|
-DSYSCONF_INSTALL_DIR:PATH=%{_sysconfdir} \\\
|
|
|
|
-DSHARE_INSTALL_PREFIX:PATH=%{_datadir} \\\
|
2016-08-26 12:34:52 +02:00
|
|
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo \\\
|
2022-06-04 10:14:02 +02:00
|
|
|
-DCMAKE_C_FLAGS="${CFLAGS:-%optflags}" \\\
|
|
|
|
-DCMAKE_CXX_FLAGS="${CXXFLAGS:-%optflags}" \\\
|
|
|
|
-DCMAKE_Fortran_FLAGS="${FFLAGS:-%optflags%{?_fmoddir: -I%_fmoddir}}" \\\
|
2023-05-08 10:37:21 +02:00
|
|
|
-DCMAKE_EXE_LINKER_FLAGS="%{?build_ldflags} -Wl,--as-needed -Wl,-z,now" \\\
|
2019-06-18 09:15:56 +02:00
|
|
|
-DCMAKE_MODULE_LINKER_FLAGS="%{?build_ldflags} -Wl,--as-needed" \\\
|
2023-05-08 10:37:21 +02:00
|
|
|
-DCMAKE_SHARED_LINKER_FLAGS="%{?build_ldflags} -Wl,--as-needed -Wl,-z,now" \\\
|
2013-08-16 11:35:44 +02:00
|
|
|
%if "%{?_lib}" == "lib64" \
|
|
|
|
-DLIB_SUFFIX=64 \\\
|
2020-03-26 09:02:45 +01:00
|
|
|
%endif \
|
2020-03-26 15:08:17 +01:00
|
|
|
%if %suse_version <= 1500 \
|
2021-09-10 12:53:10 +02:00
|
|
|
-DCMAKE_SKIP_INSTALL_RPATH:BOOL=ON \\\
|
2013-08-16 11:35:44 +02:00
|
|
|
%endif \
|
|
|
|
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \\\
|
|
|
|
-DBUILD_SHARED_LIBS:BOOL=ON \\\
|
|
|
|
-DBUILD_STATIC_LIBS:BOOL=OFF \\\
|
|
|
|
-DCMAKE_COLOR_MAKEFILE:BOOL=OFF \\\
|
|
|
|
-DCMAKE_INSTALL_DO_STRIP:BOOL=OFF \\\
|
2020-06-04 16:19:09 +02:00
|
|
|
-DCMAKE_MODULES_INSTALL_DIR=%{_libdir}/cmake/%{name}
|
2013-08-16 11:35:44 +02:00
|
|
|
|
2020-02-07 08:38:41 +01:00
|
|
|
%__builder_verbose \
|
|
|
|
%if "%__builder" == "%__make" \
|
|
|
|
%{?_make_output_sync} VERBOSE=1 \\\
|
|
|
|
%else \
|
|
|
|
-v \\\
|
|
|
|
%endif \
|
|
|
|
%{nil}
|
|
|
|
|
|
|
|
%cmake_build %__builder \\%__builder_verbose %{?_smp_mflags}
|
2014-08-20 12:42:37 +02:00
|
|
|
|
2019-01-29 11:09:31 +01:00
|
|
|
%make_jobs \
|
|
|
|
echo "Deprecated %%make_jobs macro used, please use %%cmake_build" \
|
|
|
|
%cmake_build
|
|
|
|
|
2013-08-16 11:35:44 +02:00
|
|
|
%cmake_install \
|
2020-02-07 08:58:09 +01:00
|
|
|
DESTDIR=%{buildroot} %__builder install -C %__builddir
|
2014-08-18 10:21:42 +02:00
|
|
|
|
2019-02-18 09:54:21 +01:00
|
|
|
%ctest(:-:) \
|
2016-03-08 08:29:07 +01:00
|
|
|
cd %__builddir \
|
2019-02-18 09:54:21 +01:00
|
|
|
%__ctest --output-on-failure --force-new-ctest-process %{?_smp_mflags} %** \
|
2014-08-18 10:21:42 +02:00
|
|
|
cd ..
|