Accepting request 245174 from KDE:Unstable:Frameworks

- Import some cmake handing from kf5- and kde4- filesystem to macros:
   * Simplify debug build handling in macros. Whether debug is on or off is known to optflags
   * Don't build in release mode, that cramps optimization flags; instead pass wanted flags directly
   * Pass -Wl,--as-needed -Wl,--no-undefined to linker, to avoid unneeded libs, and to disallow undefined symbols
   * Add a %make_jobs macro with verbose argument 
   * Simplify %cmake_install invocation

OBS-URL: https://build.opensuse.org/request/show/245174
OBS-URL: https://build.opensuse.org/package/show/devel:tools:building/cmake?expand=0&rev=169
This commit is contained in:
Tomáš Chvátal 2014-08-20 10:42:37 +00:00 committed by Git OBS Bridge
parent b5260f393c
commit b391c89a1a
2 changed files with 24 additions and 10 deletions

View File

@ -1,3 +1,16 @@
-------------------------------------------------------------------
Mon Aug 18 23:09:38 UTC 2014 - hrvoje.senjan@gmail.com
- Import some cmake handing from kf5- and kde4- filesystem to macros:
* Simplify debug build handling in macros. Whether debug is on
or off is known to optflags
* Don't build in release mode, that cramps optimization flags;
instead pass wanted flags directly
* Pass -Wl,--as-needed -Wl,--no-undefined to linker, to avoid
unneeded libs, and to disallow undefined symbols
* Add a %make_jobs macro with verbose argument
* Simplify %cmake_install invocation
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Aug 18 08:20:28 UTC 2014 - tchvatal@suse.com Mon Aug 18 08:20:28 UTC 2014 - tchvatal@suse.com

View File

@ -3,18 +3,12 @@
# #
%__cmake %{_bindir}/cmake %__cmake %{_bindir}/cmake
%__ctest %{_bindir}/ctest %__ctest %{_bindir}/ctest
%_cmake_debug %{?with_debug:debug}%{?!with_debug:release}
%cmake \ %cmake \
CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; \
CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; \
FFLAGS="${FFLAGS:-%optflags%{?_fmoddir: -I%_fmoddir}}" ; export FFLAGS ; \
find . -name CMakeLists.txt \\\ find . -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 /}' {} + \ -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 build \ mkdir -p build \
cd build \ cd build \
%define enable_debug 1 \
%{?_enable_debug: %{expand: %%global enable_debug 1}} \
%__cmake .. \\\ %__cmake .. \\\
-DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \\\ -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \\\
-DCMAKE_INSTALL_LIBDIR:PATH=%{_libdir} \\\ -DCMAKE_INSTALL_LIBDIR:PATH=%{_libdir} \\\
@ -22,7 +16,13 @@
-DLIB_INSTALL_DIR:PATH=%{_libdir} \\\ -DLIB_INSTALL_DIR:PATH=%{_libdir} \\\
-DSYSCONF_INSTALL_DIR:PATH=%{_sysconfdir} \\\ -DSYSCONF_INSTALL_DIR:PATH=%{_sysconfdir} \\\
-DSHARE_INSTALL_PREFIX:PATH=%{_datadir} \\\ -DSHARE_INSTALL_PREFIX:PATH=%{_datadir} \\\
-DCMAKE_BUILD_TYPE=%{_cmake_debug} \\\ -DCMAKE_BUILD_TYPE=None \\\
-DCMAKE_C_FLAGS="${CFLAGS:-%optflags} -DNDEBUG" \\\
-DCMAKE_CXX_FLAGS="${CXXFLAGS:-%optflags} -DNDEBUG" \\\
-DCMAKE_Fortran_FLAGS="${FFLAGS:-%optflags%{?_fmoddir: -I%_fmoddir}} -DNDEBUG" \\\
-DCMAKE_EXE_LINKER_FLAGS="-Wl,--as-needed -Wl,--no-undefined" \\\
-DCMAKE_MODULE_LINKER_FLAGS="-Wl,--as-needed -Wl,--no-undefined" \\\
-DCMAKE_SHARED_LINKER_FLAGS="-Wl,--as-needed -Wl,--no-undefined" \\\
%if "%{?_lib}" == "lib64" \ %if "%{?_lib}" == "lib64" \
-DLIB_SUFFIX=64 \\\ -DLIB_SUFFIX=64 \\\
%endif \ %endif \
@ -35,10 +35,11 @@
-DCMAKE_MODULES_INSTALL_DIR=%{_datadir}/cmake/Modules \\\ -DCMAKE_MODULES_INSTALL_DIR=%{_datadir}/cmake/Modules \\\
-DCMAKE_USER_MAKE_RULES_OVERRIDE="%{_datadir}/cmake/Modules/opensuse_rules.cmake" -DCMAKE_USER_MAKE_RULES_OVERRIDE="%{_datadir}/cmake/Modules/opensuse_rules.cmake"
%make_jobs \
%{__make} %{?_smp_mflags} VERBOSE=1
%cmake_install \ %cmake_install \
cd build \ make VERBOSE=1 DESTDIR=%{buildroot} install/fast -C build \
make DESTDIR=%{buildroot} install/fast \
cd ..
%ctest \ %ctest \
cd build \ cd build \