Add build, install, and test macros for CMake

CMake supports multiple generator types for builds, such as GNU Make
and Ninja. As of CMake 3.15, there are now analogs for build and install
steps typically managed directly by build tools, where CMake controls
the logic to correctly call out.

Consequently, it is now rather easy to support any given type of
build tool (as long as it's available in the build environment) and
have a CMake build "work" as expected.

This also brings CMake in line with the same build/install process
that is used for packaging Meson-based projects.
This commit is contained in:
Neal Gompa 2020-05-09 14:30:33 -04:00 committed by besser82
parent 50646f0efa
commit 4e79ea6773

View File

@ -6,6 +6,7 @@
%_cmake_skip_rpath -DCMAKE_SKIP_RPATH:BOOL=ON
%_cmake_version @@CMAKE_VERSION@@
%__cmake /usr/bin/cmake
%__ctest /usr/bin/ctest
# - Set default compile flags
# - CMAKE_*_FLAGS_RELEASE are added *after* the *FLAGS environment variables
@ -40,4 +41,19 @@
%endif \
%{?_cmake_shared_libs}
%cmake_build \
%__cmake --build "%{_vpath_builddir}" %{?_smp_mflags} --verbose
%cmake_install \
DESTDIR="%{buildroot}" %__cmake --install "%{_vpath_builddir}"
%ctest(:-:) \
cd "%{_vpath_builddir}" \
%__ctest --output-on-failure --force-new-ctest-process %{?_smp_mflags} %{**} \
cd -
%cmake@@CMAKE_MAJOR_VERSION@@ %cmake
%cmake@@CMAKE_MAJOR_VERSION@@_build %cmake_build
%cmake@@CMAKE_MAJOR_VERSION@@_install %cmake_install
%ctest@@CMAKE_MAJOR_VERSION@@ %ctest