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