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