Simon Lees
f149f52acc
- Make %cmake_build insert RELWITHDEBINFO CFLAGS as well to avoid projects overriding our %optflags with some cmake default. OBS-URL: https://build.opensuse.org/request/show/1104229 OBS-URL: https://build.opensuse.org/package/show/devel:tools:building/cmake?expand=0&rev=547
83 lines
3.5 KiB
Plaintext
83 lines
3.5 KiB
Plaintext
#
|
|
# Macros for cmake
|
|
#
|
|
%__cmake %{_bindir}/cmake
|
|
%__ctest %{_bindir}/ctest
|
|
%__builddir build
|
|
%__builder %__make
|
|
%__sourcedir .
|
|
|
|
%__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)))}
|
|
|
|
%cmake \
|
|
find %__sourcedir -type f -name CMakeLists.txt \\\
|
|
-exec sed -i -re '/^[[:blank:]]*[sS][eE][tT][[:blank:]]*\\\([[:blank:]]*(CMAKE_BUILD_TYPE|CMAKE_COLOR_MAKEFILE|CMAKE_INSTALL_PREFIX|CMAKE_VERBOSE_MAKEFILE).*\\\)/{s/^/#IGNORE /}' {} + \
|
|
mkdir -p %__builddir \
|
|
cd %__builddir \
|
|
%__cmake $OLDPWD/%__sourcedir \\\
|
|
%if "%__builder" == "%__make" \
|
|
-G"Unix Makefiles" \\\
|
|
%else \
|
|
-GNinja \\\
|
|
%endif \
|
|
-DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \\\
|
|
-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}} \\\
|
|
-DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \\\
|
|
-DLIB_INSTALL_DIR:PATH=%{_libdir} \\\
|
|
-DSYSCONF_INSTALL_DIR:PATH=%{_sysconfdir} \\\
|
|
-DSHARE_INSTALL_PREFIX:PATH=%{_datadir} \\\
|
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo \\\
|
|
-DCMAKE_C_FLAGS="${CFLAGS:-%optflags}" \\\
|
|
-DCMAKE_C_FLAGS_RELWITHDEBINFO="${CFLAGS:-%optflags}" \\\
|
|
-DCMAKE_CXX_FLAGS="${CXXFLAGS:-%optflags}" \\\
|
|
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="${CXXFLAGS:-%optflags}" \\\
|
|
-DCMAKE_Fortran_FLAGS="${FFLAGS:-%optflags%{?_fmoddir: -I%_fmoddir}}" \\\
|
|
-DCMAKE_Fortran_FLAGS_RELWITHDEBINFO="${FFLAGS:-%optflags%{?_fmoddir: -I%_fmoddir}}" \\\
|
|
-DCMAKE_EXE_LINKER_FLAGS="%{?build_ldflags} -Wl,--as-needed -Wl,-z,now" \\\
|
|
-DCMAKE_MODULE_LINKER_FLAGS="%{?build_ldflags} -Wl,--as-needed" \\\
|
|
-DCMAKE_SHARED_LINKER_FLAGS="%{?build_ldflags} -Wl,--as-needed -Wl,-z,now" \\\
|
|
%if "%{?_lib}" == "lib64" \
|
|
-DLIB_SUFFIX=64 \\\
|
|
%endif \
|
|
%if %suse_version <= 1500 \
|
|
-DCMAKE_SKIP_INSTALL_RPATH:BOOL=ON \\\
|
|
%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 \\\
|
|
-DCMAKE_MODULES_INSTALL_DIR=%{_libdir}/cmake/%{name}
|
|
|
|
%__builder_verbose \
|
|
%if "%__builder" == "%__make" \
|
|
%{?_make_output_sync} VERBOSE=1 \\\
|
|
%else \
|
|
-v \\\
|
|
%endif \
|
|
%{nil}
|
|
|
|
%cmake_build %__builder \\%__builder_verbose %{?_smp_mflags}
|
|
|
|
%make_jobs \
|
|
echo "Deprecated %%make_jobs macro used, please use %%cmake_build" \
|
|
%cmake_build
|
|
|
|
%cmake_install \
|
|
DESTDIR=%{buildroot} %__builder install -C %__builddir
|
|
|
|
%ctest(:-:) \
|
|
cd %__builddir \
|
|
%__ctest --output-on-failure --force-new-ctest-process %{?_smp_mflags} %** \
|
|
cd ..
|