diff --git a/cmake.spec b/cmake.spec index dc614f0913a5a7f654e4ca72b5ea1157beae0461..7f97af7e1abe05dc9e00b3a91a67419402eb2243 100644 --- a/cmake.spec +++ b/cmake.spec @@ -14,6 +14,11 @@ %bcond_without sphinx %endif +# Do not build non-lto objects to reduce build time significantly. +%global build_cflags %(echo '%{build_cflags}' | sed -e 's!-ffat-lto-objects!-fno-fat-lto-objects!g') +%global build_cxxflags %(echo '%{build_cxxflags}' | sed -e 's!-ffat-lto-objects!-fno-fat-lto-objects!g') +%global build_fflags %(echo '%{build_fflags}' | sed -e 's!-ffat-lto-objects!-fno-fat-lto-objects!g') +%global build_fcflags %(echo '%{build_fflags}' | sed -e 's!-ffat-lto-objects!-fno-fat-lto-objects!g') %global rpm_macros_dir %(d=%{_rpmconfigdir}/macros.d; [ -d $d ] || d=%{_sysconfdir}/rpm; echo $d) %{!?_pkgdocdir:%global _pkgdocdir %{_docdir}/cmake-%{version}} @@ -22,13 +27,14 @@ Name: cmake Version: 3.27.9 -Release: 5 +%global major_version %(echo %{version} | awk -F. '{print $1}') +Release: 6 Summary: Cross-platform make system -License: BSD and MIT and zlib +License: BSD-3-Clause AND MIT-open-group AND Zlib URL: http://www.cmake.org Source0: https://www.cmake.org/files/v3.27/cmake-%{version}.tar.gz Source1: cmake-init.el -Source2: macros.cmake +Source2: macros.cmake.in Source3: cmake.attr Source4: cmake.prov Source5: cmake.req @@ -144,8 +150,8 @@ tail -n +2 %{SOURCE5} >> %{name}.req export CFLAGS=`echo %{optflags} | sed 's/-g\b/-s/g'` export CXXFLAGS=`echo %{optflags} | sed 's/-g\b/-s/g'` export LDFLAGS="%{?__global_ldflags}" -mkdir build -pushd build +mkdir %{_vpath_builddir} +pushd %{_vpath_builddir} ../bootstrap --prefix=%{_prefix} --datadir=/share/cmake \ --docdir=/share/doc/cmake --mandir=/share/man \ --%{?with_bootstrap:no-}system-libs \ @@ -163,11 +169,13 @@ pushd build %endif %endif ; -%make_build VERBOSE=1 +popd + +%make_build -C %{_vpath_builddir} %install install -d %{buildroot}%{_pkgdocdir} -%make_install -C build CMAKE_DOC_DIR=%{buildroot}%{_pkgdocdir} +%make_install -C %{_vpath_builddir} CMAKE_DOC_DIR=%{buildroot}%{_pkgdocdir} find %{buildroot}%{_datadir}/cmake/Modules -type f | xargs chmod -x for f in ccmake cmake cpack ctest; do @@ -184,10 +192,10 @@ install -p -m 0644 %SOURCE1 %{buildroot}%{_emacs_sitestartdir} rm -f %{buildroot}%{_emacs_sitelispdir} %endif -install -p -m0644 -D %{SOURCE2} %{buildroot}%{rpm_macros_dir}/macros.cmake -sed -i -e "s|@@CMAKE_VERSION@@|%{version}|" -e "s|@@CMAKE_MAJOR_VERSION@@|3|" %{buildroot}%{rpm_macros_dir}/macros.cmake -touch -r %{SOURCE2} %{buildroot}%{rpm_macros_dir}/macros.cmake -install -p -m0644 -D %{SOURCE3} %{buildroot}%{_prefix}/lib/rpm/fileattrs/cmake.attr +install -p -m0644 -D %{S:2} %{buildroot}%{rpm_macros_dir}/macros.%{name} +sed -i -e "s|@@CMAKE_VERSION@@|%{version}|" -e "s|@@CMAKE_MAJOR_VERSION@@|%{major_version}|" %{buildroot}%{rpm_macros_dir}/macros.%{name} +touch -r %{S:2} %{buildroot}%{rpm_macros_dir}/macros.%{name} +install -p -m0644 -D %{S:3} %{buildroot}%{_prefix}/lib/rpm/fileattrs/cmake.attr install -p -m0755 -D cmake.prov %{buildroot}%{_prefix}/lib/rpm/cmake.prov install -p -m0755 -D cmake.req %{buildroot}%{_prefix}/lib/rpm/cmake.req install -d %{buildroot}%{_libdir}/cmake @@ -223,9 +231,18 @@ find %{buildroot}%{_bindir} -type f -or -type l -or -xtype l | \ sed -e '/.*-gui$/d' -e '/^$/d' -e 's!^%{buildroot}!"!g' -e 's!$!"!g' >> lib_files.mf %check -#cd build -#export NO_TEST="CMake.FileDownload|CTestTestUpload|curl|RunCMake.CPack_RPM" -#bin/ctest -V -E "$NO_TEST" %{?_smp_mflags} +pushd %{_vpath_builddir} +# CTestTestUpload requires internet access. +NO_TEST="CTestTestUpload" +# Likely failing for hardening flags from system. +NO_TEST="$NO_TEST|CustomCommand|RunCMake.PositionIndependentCode" +%ifarch riscv64 +# These three tests timeout on riscv64, skip them. +NO_TEST="$NO_TEST|Qt5Autogen.ManySources|Qt5Autogen.MocInclude|Qt5Autogen.MocIncludeSymlink|Qt6Autogen.MocIncludeSymlink" +%endif +bin/ctest%{?name_suffix} %{?_smp_mflags} -V -E "$NO_TEST" --output-on-failure +popd + %if %{with cmake_gui} %post gui @@ -299,6 +316,10 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : %exclude %{_pkgdocdir}/Copyright.txt %changelog +* Mon Sep 02 2024 Funda Wang - 3.27.9-6 +- make use of _vpath_builddir, but default to in source build for backward compatibility +- enable check section + * Thu Aug 22 2024 Dongxing Wang - 3.27.9-5 - Support %cmake_build and %cmake_install. diff --git a/macros.cmake b/macros.cmake.in similarity index 47% rename from macros.cmake rename to macros.cmake.in index 1acbf460741ddfb0c606b5ae2728208beaa971e5..e50a99efe63ae2620594e3fbf8eb7dd9fec862ec 100644 --- a/macros.cmake +++ b/macros.cmake.in @@ -1,50 +1,28 @@ # # Macros for cmake # + +%__cmake_in_source_build 1 + %_cmake_lib_suffix64 -DLIB_SUFFIX=64 +%_cmake_lib_suffixilp32 -DLIB_SUFFIX=ilp32 +%_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:.} +%_cmake_module_linker_flags %(echo %build_ldflags|sed -e 's#-Wl,--no-undefined##') # - 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 \ - CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; \ - CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; \ - FFLAGS="${FFLAGS:-%optflags%{?_fmoddir: -I%_fmoddir}}" ; export FFLAGS ; \ - FCFLAGS="${FCFLAGS:-%optflags%{?_fmoddir: -I%_fmoddir}}" ; export FCFLAGS ; \ - %{?__global_ldflags:LDFLAGS="${LDFLAGS:-%__global_ldflags}" ; export LDFLAGS ;} \ - %__cmake \\\ - -DCMAKE_C_FLAGS_RELEASE:STRING="-DNDEBUG" \\\ - -DCMAKE_CXX_FLAGS_RELEASE:STRING="-DNDEBUG" \\\ - -DCMAKE_Fortran_FLAGS_RELEASE:STRING="-DNDEBUG" \\\ - -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \\\ - -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \\\ - -DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \\\ - -DLIB_INSTALL_DIR:PATH=%{_libdir} \\\ - -DSYSCONF_INSTALL_DIR:PATH=%{_sysconfdir} \\\ - -DSHARE_INSTALL_PREFIX:PATH=%{_datadir} \\\ -%if "%{?_lib}" == "lib64" \ - %{?_cmake_lib_suffix64} \\\ -%endif \ -%if "%{?_lib}" == "libilp32" \ - -DLIB_SUFFIX=ilp32 \\\ -%endif \ - -DBUILD_SHARED_LIBS:BOOL=ON - -# cmake for cmake_build and cmake_install -%cmake_conf \ - CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; \ - CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; \ - FFLAGS="${FFLAGS:-%optflags%{?_fmoddir: -I%_fmoddir}}" ; export FFLAGS ; \ - FCFLAGS="${FCFLAGS:-%optflags%{?_fmoddir: -I%_fmoddir}}" ; export FCFLAGS ; \ - %{?__global_ldflags:LDFLAGS="${LDFLAGS:-%__global_ldflags}" ; export LDFLAGS ;} \ + %{set_build_flags} \ %__cmake \\\ %{!?__cmake_in_source_build:-S "%{_vpath_srcdir}"} \\\ %{!?__cmake_in_source_build:-B "%{__cmake_builddir}"} \\\ @@ -52,18 +30,24 @@ -DCMAKE_CXX_FLAGS_RELEASE:STRING="-DNDEBUG" \\\ -DCMAKE_Fortran_FLAGS_RELEASE:STRING="-DNDEBUG" \\\ -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \\\ + -DCMAKE_INSTALL_DO_STRIP:BOOL=OFF \\\ -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \\\ -DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \\\ -DLIB_INSTALL_DIR:PATH=%{_libdir} \\\ -DSYSCONF_INSTALL_DIR:PATH=%{_sysconfdir} \\\ + -DCMAKE_INSTALL_RUNSTATEDIR:PATH=%{_rundir} \\\ -DSHARE_INSTALL_PREFIX:PATH=%{_datadir} \\\ %if "%{?_lib}" == "lib64" \ %{?_cmake_lib_suffix64} \\\ %endif \ %if "%{?_lib}" == "libilp32" \ - -DLIB_SUFFIX=ilp32 \\\ + %{?_cmake_lib_suffixilp32} \\\ %endif \ - -DBUILD_SHARED_LIBS:BOOL=ON + %{?_cmake_shared_libs} \\\ + %{?_cmake_module_linker_flags:-DCMAKE_MODULE_LINKER_FLAGS="%_cmake_module_linker_flags%{?_cmake_module_linker_flags_extra: %_cmake_module_linker_flags_extra}"} \\\ + %{nil} + +%cmake_conf %cmake %cmake_build \ %__cmake --build "%{__cmake_builddir}" %{?_smp_mflags} --verbose @@ -71,13 +55,26 @@ %cmake_install \ DESTDIR="%{buildroot}" %__cmake --install "%{__cmake_builddir}" -%ctest(:-:) \ -cd "%{__cmake_builddir}" \ -%__ctest --output-on-failure --force-new-ctest-process %{?_smp_mflags} %{**} \ -cd - +%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 \\\ +%ifarch riscv64 \ + --timeout 6000 \\\ +%endif \ + %{?_smp_mflags} %{**} + %cmake@@CMAKE_MAJOR_VERSION@@ %cmake -%cmake@@CMAKE_MAJOR_VERSION@@_conf %cmake_conf %cmake@@CMAKE_MAJOR_VERSION@@_build %cmake_build %cmake@@CMAKE_MAJOR_VERSION@@_install %cmake_install -%ctest@@CMAKE_MAJOR_VERSION@@(:-:) %ctest %{**} +%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 %{**} + +# Declarative buildsystem, requires RPM 4.20+ to work +# https://rpm-software-management.github.io/rpm/manual/buildsystem.html +%buildsystem_cmake_generate_buildrequires() %{nil} +%buildsystem_cmake_conf() %cmake %* +%buildsystem_cmake_build() %cmake_build %* +%buildsystem_cmake_install() %cmake_install %* +%buildsystem_cmake_check(:-:h:j:u:v:A:C:D:E:F:H:I:L:M:N:O:Q:R:S:T:U:V:) %ctest %{**}