#1 Sync Fedora macros for optional support for out-of-source builds
Closed 3 years ago by carlwgeorge. Opened 4 years ago by ngompa.

file modified
+21 -1
@@ -6,6 +6,9 @@ 

  %_cmake_skip_rpath -DCMAKE_SKIP_RPATH:BOOL=ON

  %_cmake_version @@CMAKE_VERSION@@

  %__cmake /usr/bin/cmake

+ %__ctest /usr/bin/ctest

+ %__cmake_in_source_build 1

+ %__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
@@ -24,6 +27,8 @@ 

    %{?__global_ldflags:LDFLAGS="${LDFLAGS:-%__global_ldflags}" ; export LDFLAGS ;} \

  %endif \

    %__cmake \\\

+         %{!?__cmake_in_source_build:-S "%{_vpath_srcdir}"} \\\

+         %{!?__cmake_in_source_build:-B "%{__cmake_builddir}"} \\\

          -DCMAKE_C_FLAGS_RELEASE:STRING="-DNDEBUG" \\\

          -DCMAKE_CXX_FLAGS_RELEASE:STRING="-DNDEBUG" \\\

          -DCMAKE_Fortran_FLAGS_RELEASE:STRING="-DNDEBUG" \\\
@@ -36,6 +41,21 @@ 

  %if "%{?_lib}" == "lib64" \

          %{?_cmake_lib_suffix64} \\\

  %endif \

- 	%{?_cmake_shared_libs}

+         %{?_cmake_shared_libs}

+ 

+ %cmake_build \

+   %__cmake --build "%{__cmake_builddir}" %{?_smp_mflags} --verbose

+ 

+ %cmake_install \

+   DESTDIR="%{buildroot}" %__cmake --install "%{__cmake_builddir}"

+ 

+ %ctest(:-:) \

+   cd "%{__cmake_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

These are synced from the version of these macros for Fedora 31/32,
which default to in-source builds but support out-of-source builds
when %__cmake_in_source_build is undefined.

Additionally, this introduces the generic %cmake_build, %cmake_install,
and %ctest macros for controlling a CMake build regardless of chosen
backend.

Reference: https://fedoraproject.org/wiki/Changes/CMake_to_do_out-of-source_builds

The cmake version in RHEL8/CentOS8 (3.11.4) sadly does not support the -S and -B options.

Unless you can persuade redhat to update it to a less ancient version, you need to rewrite the macro not to use them.

I hope you can persuade them to update the version.

CentOS usually only rebuilds what is in RHEL, unless there is a CentOS specific bug. Shouldn't this change be requested in RHEL first, and then imported to CentOS from there if accepted.

You might have better luck with suggesting overriding RHEL8's definition of the %cmake macro in epel-rpm-macros. You would still have to reimplement it without using -S and -B though.

This has been addressed in rhbz#1858983 and released as cmake-3.18.2-9.el8.

Pull-Request has been closed by carlwgeorge

3 years ago
Metadata