From dfb163631bbc2ced2af6a4e163cbe2da4668b370 Mon Sep 17 00:00:00 2001 From: lwg Date: Mon, 8 Jan 2024 15:16:31 +0800 Subject: [PATCH] add cmake_build, cmake_install and ctest macros --- cmake.spec | 5 ++++- macros.cmake | 21 +++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/cmake.spec b/cmake.spec index dca13e0..6158c77 100644 --- a/cmake.spec +++ b/cmake.spec @@ -11,7 +11,7 @@ Name: cmake Version: 3.24.3 -Release: 2 +Release: 3 Summary: Cross-platform make system License: BSD and MIT and zlib URL: http://www.cmake.org @@ -236,6 +236,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : %exclude %{_pkgdocdir}/Copyright.txt %changelog +* Mon Jan 08 2024 Paul Thomas - 3.24.3-3 +- add cmake_build, cmake_install and ctest macros + * Thu Dec 14 2023 liyanan - 3.24.3-2 - Fix abnormal empty link in cmake-data package diff --git a/macros.cmake b/macros.cmake index 1768aab..5d8dbc1 100644 --- a/macros.cmake +++ b/macros.cmake @@ -2,14 +2,18 @@ # Macros for cmake # %_cmake_lib_suffix64 -DLIB_SUFFIX=64 +%_cmake_shared_libs -DBUILD_SHARED_LIBS:BOOL=ON %_cmake_skip_rpath -DCMAKE_SKIP_RPATH:BOOL=ON %_cmake_version @@CMAKE_VERSION@@ %__cmake /usr/bin/cmake +%__ctest /usr/bin/ctest +%__cmake_builddir %{!?__cmake_in_source_build:%{_vpath_builddir}}%{?__cmake_in_source_build:.} # - Set default compile flags # - CMAKE_*_FLAGS_RELEASE are added *after* the *FLAGS environment variables -# and default to -O3 -DNDEBUG. Strip the -O3 so we can override with *FLAGS +# and default to -O3 -DNDEBUG. Strip the -O3 so we can override with *FLAGS # - Turn on verbose makefiles so we can see and verify compile flags +# - Turn off stripping by default so RPM can do it separately # - Set default install prefixes and library install directories # - Turn on shared libraries by default %cmake \ @@ -31,6 +35,19 @@ %if "%{?_lib}" == "lib64" \ %{?_cmake_lib_suffix64} \\\ %endif \ - -DBUILD_SHARED_LIBS:BOOL=ON + -DBUILD_SHARED_LIBS:BOOL=ON + +%cmake_build \ + %__cmake --build "%{__cmake_builddir}" %{?_smp_mflags} --verbose + +%cmake_install \ + DESTDIR="%{buildroot}" %__cmake --install "%{__cmake_builddir}" + +%ctest(:-:h:j:u:v:A:C:D:E:F:H:I:L:M:N:O:Q:R:S:T:U:V:) \ + %__ctest --test-dir "%{__cmake_builddir}" --output-on-failure --force-new-ctest-process %{?_smp_mflags} %{**} %cmake@@CMAKE_MAJOR_VERSION@@ %cmake +%cmake@@CMAKE_MAJOR_VERSION@@_build %cmake_build +%cmake@@CMAKE_MAJOR_VERSION@@_install %cmake_install +%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:) \ + %ctest %{**} -- Gitee