1c6c4f
#
1c6c4f
# Macros for cmake
1c6c4f
#
1c6c4f
%_cmake_lib_suffix64 -DLIB_SUFFIX=64
1c6c4f
%_cmake_shared_libs -DBUILD_SHARED_LIBS:BOOL=ON
1c6c4f
%_cmake_skip_rpath -DCMAKE_SKIP_RPATH:BOOL=ON
1c6c4f
%_cmake_version @@CMAKE_VERSION@@
1c6c4f
%__cmake /usr/bin/cmake
1c6c4f
%__ctest /usr/bin/ctest
1c6c4f
%__cmake_builddir %{!?__cmake_in_source_build:%{_vpath_builddir}}%{?__cmake_in_source_build:.}
1c6c4f
1c6c4f
1c6c4f
# - Set default compile flags
1c6c4f
# - CMAKE_*_FLAGS_RELEASE are added *after* the *FLAGS environment variables
1c6c4f
#   and default to -O3 -DNDEBUG.  Strip the -O3 so we can override with *FLAGS
1c6c4f
# - Turn on verbose makefiles so we can see and verify compile flags
1c6c4f
# - Turn off stripping by default so RPM can do it separately
1c6c4f
# - Set default install prefixes and library install directories
1c6c4f
# - Turn on shared libraries by default
1c6c4f
%cmake \
1c6c4f
  %{set_build_flags} \
1c6c4f
  %__cmake \\\
1c6c4f
        %{!?__cmake_in_source_build:-S "%{_vpath_srcdir}"} \\\
1c6c4f
        %{!?__cmake_in_source_build:-B "%{__cmake_builddir}"} \\\
1c6c4f
        -DCMAKE_C_FLAGS_RELEASE:STRING="-DNDEBUG" \\\
1c6c4f
        -DCMAKE_CXX_FLAGS_RELEASE:STRING="-DNDEBUG" \\\
1c6c4f
        -DCMAKE_Fortran_FLAGS_RELEASE:STRING="-DNDEBUG" \\\
1c6c4f
        -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \\\
1c6c4f
        -DCMAKE_INSTALL_DO_STRIP:BOOL=OFF \\\
1c6c4f
        -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \\\
1c6c4f
        -DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \\\
1c6c4f
        -DLIB_INSTALL_DIR:PATH=%{_libdir} \\\
1c6c4f
        -DSYSCONF_INSTALL_DIR:PATH=%{_sysconfdir} \\\
1c6c4f
        -DSHARE_INSTALL_PREFIX:PATH=%{_datadir} \\\
1c6c4f
%if "%{?_lib}" == "lib64" \
1c6c4f
        %{?_cmake_lib_suffix64} \\\
1c6c4f
%endif \
1c6c4f
        %{?_cmake_shared_libs}
1c6c4f
1c6c4f
%cmake_build \
1c6c4f
  %__cmake --build "%{__cmake_builddir}" %{?_smp_mflags} --verbose
1c6c4f
1c6c4f
%cmake_install \
1c6c4f
  DESTDIR="%{buildroot}" %__cmake --install "%{__cmake_builddir}"
1c6c4f
1c6c4f
%ctest(:-:h:j:u:v:A:C:D:E:F:H:I:L:M:N:O:Q:R:S:T:U:V:) \
1c6c4f
  %__ctest --test-dir "%{__cmake_builddir}" --output-on-failure --force-new-ctest-process %{?_smp_mflags} %{**}
1c6c4f
1c6c4f
1c6c4f
%cmake@@CMAKE_MAJOR_VERSION@@ %cmake
1c6c4f
%cmake@@CMAKE_MAJOR_VERSION@@_build %cmake_build
1c6c4f
%cmake@@CMAKE_MAJOR_VERSION@@_install %cmake_install
1c6c4f
%ctest@@CMAKE_MAJOR_VERSION@@(:-:h:j:u:v:A:C:D:E:F:H:I:L:M:N:O:Q:R:S:T:U:V:) \
1c6c4f
  %ctest %{**}