2576bb
#
2576bb
# Macros for cmake
2576bb
#
2576bb
%_cmake_lib_suffix64 -DLIB_SUFFIX=64
348aeb
%_cmake_shared_libs -DBUILD_SHARED_LIBS:BOOL=ON
2576bb
%_cmake_skip_rpath -DCMAKE_SKIP_RPATH:BOOL=ON
2576bb
%_cmake_version @@CMAKE_VERSION@@
2576bb
%__cmake /usr/bin/cmake
348aeb
%__ctest /usr/bin/ctest
348aeb
%__cmake_in_source_build 1
348aeb
%__cmake_builddir %{!?__cmake_in_source_build:%{_vpath_builddir}}%{?__cmake_in_source_build:.}
2576bb
2576bb
# - Set default compile flags
2576bb
# - CMAKE_*_FLAGS_RELEASE are added *after* the *FLAGS environment variables
2576bb
# and default to -O3 -DNDEBUG.  Strip the -O3 so we can override with *FLAGS
2576bb
# - Turn on verbose makefiles so we can see and verify compile flags
2576bb
# - Set default install prefixes and library install directories
2576bb
# - Turn on shared libraries by default
2576bb
%cmake \
348aeb
%if 0%{?set_build_flags:1} \
348aeb
  %set_build_flags \
348aeb
%else \
2576bb
  CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; \
2576bb
  CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; \
2576bb
  FFLAGS="${FFLAGS:-%optflags%{?_fmoddir: -I%_fmoddir}}" ; export FFLAGS ; \
2576bb
  FCFLAGS="${FCFLAGS:-%optflags%{?_fmoddir: -I%_fmoddir}}" ; export FCFLAGS ; \
2576bb
  %{?__global_ldflags:LDFLAGS="${LDFLAGS:-%__global_ldflags}" ; export LDFLAGS ;} \
348aeb
%endif \
2576bb
  %__cmake \\\
348aeb
        %{!?__cmake_in_source_build:-S "%{_vpath_srcdir}"} \\\
348aeb
        %{!?__cmake_in_source_build:-B "%{__cmake_builddir}"} \\\
2576bb
        -DCMAKE_C_FLAGS_RELEASE:STRING="-DNDEBUG" \\\
2576bb
        -DCMAKE_CXX_FLAGS_RELEASE:STRING="-DNDEBUG" \\\
2576bb
        -DCMAKE_Fortran_FLAGS_RELEASE:STRING="-DNDEBUG" \\\
2576bb
        -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \\\
2576bb
        -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \\\
2576bb
        -DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \\\
2576bb
        -DLIB_INSTALL_DIR:PATH=%{_libdir} \\\
2576bb
        -DSYSCONF_INSTALL_DIR:PATH=%{_sysconfdir} \\\
2576bb
        -DSHARE_INSTALL_PREFIX:PATH=%{_datadir} \\\
2576bb
%if "%{?_lib}" == "lib64" \
2576bb
        %{?_cmake_lib_suffix64} \\\
2576bb
%endif \
348aeb
        %{?_cmake_shared_libs}
348aeb
348aeb
%cmake_build \
348aeb
  %__cmake --build "%{__cmake_builddir}" %{?_smp_mflags} --verbose
348aeb
348aeb
%cmake_install \
348aeb
  DESTDIR="%{buildroot}" %__cmake --install "%{__cmake_builddir}"
348aeb
348aeb
%ctest(:-:) \
348aeb
  cd "%{__cmake_builddir}" \
348aeb
  %__ctest --output-on-failure --force-new-ctest-process %{?_smp_mflags} %{**} \
348aeb
  cd -
348aeb
2576bb
2576bb
%cmake@@CMAKE_MAJOR_VERSION@@ %cmake
348aeb
%cmake@@CMAKE_MAJOR_VERSION@@_build %cmake_build
348aeb
%cmake@@CMAKE_MAJOR_VERSION@@_install %cmake_install
348aeb
%ctest@@CMAKE_MAJOR_VERSION@@(:-:) %ctest %{**}