diff --git a/README.md b/README.md deleted file mode 100644 index 7342728d557c602f51c6d278bba9f3dd9faaf356..0000000000000000000000000000000000000000 --- a/README.md +++ /dev/null @@ -1,11 +0,0 @@ -Anolis OS -======================================= -# 代码仓库说明 -## 分支说明 ->进行代码开发工作时,请注意选择当前版本对应的分支 -* aX分支为对应大版本的主分支,如a8分支对应当前最新版本 -* aX.Y分支为对应小版本的维护分支,如a8.2分支对应8.2版本 -## 开发流程 -1. 首先fork目标分支到自己的namespace -2. 在自己的fork分支上做出修改 -3. 向对应的仓库中提交merge request,源分支为fork分支 diff --git a/cmake-3.22.3.tar.gz b/cmake-3.22.3.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..51b7689c5cfe4cf88948e2ffaee7cbc001015939 Binary files /dev/null and b/cmake-3.22.3.tar.gz differ diff --git a/cmake-findruby.patch b/cmake-findruby.patch new file mode 100644 index 0000000000000000000000000000000000000000..23966a22421f334e24373a1e43c920b3aaf40e92 --- /dev/null +++ b/cmake-findruby.patch @@ -0,0 +1,22 @@ +Index: cmake-3.22.0-rc1/Modules/FindRuby.cmake +=================================================================== +--- cmake-3.22.0-rc1.orig/Modules/FindRuby.cmake ++++ cmake-3.22.0-rc1/Modules/FindRuby.cmake +@@ -304,14 +304,9 @@ if(Ruby_EXECUTABLE AND NOT Ruby_VERSION_ + _RUBY_CONFIG_VAR("sitearchdir" Ruby_SITEARCH_DIR) + _RUBY_CONFIG_VAR("sitelibdir" Ruby_SITELIB_DIR) + +- # vendor_ruby available ? +- execute_process(COMMAND ${Ruby_EXECUTABLE} -r vendor-specific -e "print 'true'" +- OUTPUT_VARIABLE Ruby_HAS_VENDOR_RUBY ERROR_QUIET) +- +- if(Ruby_HAS_VENDOR_RUBY) +- _RUBY_CONFIG_VAR("vendorlibdir" Ruby_VENDORLIB_DIR) +- _RUBY_CONFIG_VAR("vendorarchdir" Ruby_VENDORARCH_DIR) +- endif() ++ # vendor_ruby ++ _RUBY_CONFIG_VAR("vendorlibdir" Ruby_VENDORLIB_DIR) ++ _RUBY_CONFIG_VAR("vendorarchdir" Ruby_VENDORARCH_DIR) + + # save the results in the cache so we don't have to run ruby the next time again + set(Ruby_VERSION_MAJOR ${Ruby_VERSION_MAJOR} CACHE PATH "The Ruby major version" FORCE) diff --git a/cmake-init.el b/cmake-init.el new file mode 100644 index 0000000000000000000000000000000000000000..a5e0e2ef928184dc7ee311bf11f77e34e3d89e86 --- /dev/null +++ b/cmake-init.el @@ -0,0 +1,9 @@ +;; +;; Setup cmake-mode for autoloading +;; +(autoload 'cmake-mode "cmake-mode" "Major mode for editing CMake listfiles." t) +(setq auto-mode-alist + (append + '(("CMakeLists\\.txt\\'" . cmake-mode)) + '(("\\.cmake\\'" . cmake-mode)) + auto-mode-alist)) diff --git a/cmake-mingw-dl.patch b/cmake-mingw-dl.patch new file mode 100644 index 0000000000000000000000000000000000000000..8b0135ee7621277c250b8d8a27b698a7a060e115 --- /dev/null +++ b/cmake-mingw-dl.patch @@ -0,0 +1,18 @@ +Index: cmake-3.22.0-rc1/Modules/Platform/Windows-GNU.cmake +=================================================================== +--- cmake-3.22.0-rc1.orig/Modules/Platform/Windows-GNU.cmake ++++ cmake-3.22.0-rc1/Modules/Platform/Windows-GNU.cmake +@@ -24,11 +24,11 @@ set(CMAKE_STATIC_LIBRARY_SUFFIX ".a") + set(CMAKE_EXTRA_LINK_EXTENSIONS ".lib") # MinGW can also link to a MS .lib + + set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "") +-set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a" ".lib") ++set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ".dll.a" ".a" ".lib") + set(CMAKE_C_STANDARD_LIBRARIES_INIT "-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32") + set(CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}") + +-set(CMAKE_DL_LIBS "") ++set(CMAKE_DL_LIBS "dl") + set(CMAKE_LIBRARY_PATH_FLAG "-L") + set(CMAKE_LINK_LIBRARY_FLAG "-l") + set(CMAKE_LINK_DEF_FILE_FLAG "") # Empty string: passing the file is enough diff --git a/cmake.attr b/cmake.attr new file mode 100644 index 0000000000000000000000000000000000000000..83f3f1ae3228e1bc7478e9bef885dc9eae3418cd --- /dev/null +++ b/cmake.attr @@ -0,0 +1,3 @@ +%__cmake_provides %{_rpmconfigdir}/cmake.prov +%__cmake_requires %{_rpmconfigdir}/cmake.req +%__cmake_path ^(%{_libdir}|%{_datadir})/cmake/.*/.*(Config\.cmake|-config\.cmake)$ diff --git a/cmake.prov b/cmake.prov new file mode 100644 index 0000000000000000000000000000000000000000..58d3522b3607d17d31adddb6537f63f8a713a4ec --- /dev/null +++ b/cmake.prov @@ -0,0 +1,82 @@ +#!/usr/bin/python3 +# -*- coding:utf-8 -*- +# +# Copyright (C) 2015 Daniel Vrátil +# Copyright (C) 2017 Daniel Vrátil +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this program; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +import sys +import re +import glob + +class CMakeParser: + def __init__(self, filelist = None): + if filelist == None: + filelist = sys.stdin + + paths = map(lambda x: x.rstrip(), filelist.readlines()) + for path in paths: + modulePath, cmakeModule, lowercase = self.parseCmakeModuleConfig(path) + if modulePath and cmakeModule: + version = self.resolveCMakeModuleVersion(modulePath, cmakeModule, lowercase) + + if version: + string = "cmake(" + cmakeModule + ") = " + version + else: + string = "cmake(" + cmakeModule + ")" + if string == string.lower(): + print(string) + else: + # Temporarily print both variants to satisfy requires + # by the old version of this generator which made mistakes + print(string) + print(string.lower()) + + + def parseCmakeModuleConfig(self, configFile): + paths = configFile.rsplit("/", 3) + + modulePath = "%s/cmake/%s" % (paths[0], paths[2]) + cfgFile = paths[3] + if cfgFile.endswith("Config.cmake"): + return (modulePath, cfgFile[0:-len("Config.cmake")], False) + elif cfgFile.endswith("-config.cmake"): + return (modulePath, cfgFile[0:-len("-config.cmake")], True) + else: + return (None, None, False) + + def resolveCMakeModuleVersion(self, modulePath, cmakeModule, lowercase): + versionFile = ("%s/%s-config-version.cmake" if lowercase else "%s/%sConfigVersion.cmake") % (modulePath, cmakeModule) + try: + f = open(versionFile, 'r') + except: + return None + + for line in f: + line = line.strip() + + # set(PACKAGE_VERSION ) + version = re.match(r"^set[\ ]*\([\ ]*PACKAGE_VERSION[\ ]+[\"]*([0-9\.]+)[\"]*[\ ]*[.]*\)", line) + if version: + return version.groups(1)[0] + + return None + +if __name__ == "__main__": + parser = CMakeParser() diff --git a/cmake.req b/cmake.req new file mode 100644 index 0000000000000000000000000000000000000000..9af5c44e986d951bdbf2e695003bb9b44d16a39e --- /dev/null +++ b/cmake.req @@ -0,0 +1,70 @@ +#!/usr/bin/python3 +# -*- coding:utf-8 -*- +# +# Copyright (C) 2017 Björn Esser +# +# based on cmake.prov, which is +# Copyright (C) 2015 Daniel Vrátil +# Copyright (C) 2017 Daniel Vrátil +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this program; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +import sys +import re +import subprocess + +class CMakeParser: + def __init__(self, filelist = None): + if filelist == None: + filelist = sys.stdin + + has_module = False + is_arched = False + + isa_suf = subprocess.check_output(["/usr/bin/rpm", "-E %{?_isa}"]).decode().strip() + + paths = map(lambda x: x.rstrip(), filelist.readlines()) + for path in paths: + modulePath, cmakeModule, lowercase = self.parseCmakeModuleConfig(path) + if modulePath and cmakeModule: + has_module = True + if re.match(".*/usr/lib(64)?/cmake/.*", modulePath): + is_arched = True + + if has_module: + if is_arched: + print("cmake-filesystem%s" % isa_suf) + else: + print("cmake-filesystem") + + + def parseCmakeModuleConfig(self, configFile): + paths = configFile.rsplit("/", 3) + + modulePath = "%s/cmake/%s" % (paths[0], paths[2]) + cfgFile = paths[3] + if cfgFile.endswith("Config.cmake"): + return (modulePath, cfgFile[0:-len("Config.cmake")], False) + elif cfgFile.endswith("-config.cmake"): + return (modulePath, cfgFile[0:-len("-config.cmake")], True) + else: + return (None, None, False) + + +if __name__ == "__main__": + parser = CMakeParser() diff --git a/cmake.spec b/cmake.spec new file mode 100644 index 0000000000000000000000000000000000000000..9bc6783bb918623e23b9f984e9486161382dc9d6 --- /dev/null +++ b/cmake.spec @@ -0,0 +1,344 @@ +%bcond_with bootstrap +%bcond_without emacs +%bcond_without git_test +%bcond_without gui +%bcond_without ncurses +%bcond_without sphinx +%bcond_without bundled_jsoncpp +%bcond_without bundled_rhash +%bcond_without test +%bcond_without X11_test + +%global optflags %(echo '%{optflags}' | 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}/%{name}-%{version}} + +%{!?_vpath_builddir:%global _vpath_builddir %{_target_platform}} + +%global major_version 3 +%global minor_version 22 + +Name: cmake +Version: 3.22.3 +Release: 1%{?dist} +Summary: Cross-platform make system + +License: BSD and MIT and zlib +URL: http://www.cmake.org +Source0: http://www.cmake.org/files/v%{major_version}.%{minor_version}/%{name}-%{version}.tar.gz +Source1: %{name}-init.el +Source2: macros.%{name} +Source3: %{name}.attr +Source4: %{name}.prov +Source5: %{name}.req + +Patch100: %{name}-findruby.patch +Patch102: %{name}-mingw-dl.patch + +BuildRequires: coreutils +BuildRequires: findutils +BuildRequires: gcc-c++ +BuildRequires: gcc-gfortran +BuildRequires: sed +%if %{with git_test} +BuildRequires: git +%else +BuildConflicts: git-core +%endif +%if %{with X11_test} +BuildRequires: libX11-devel +%endif +%if %{with ncurses} +BuildRequires: ncurses-devel +%endif +%if %{with sphinx} +BuildRequires: %{_bindir}/sphinx-build +%endif +%if %{without bootstrap} +BuildRequires: bzip2-devel +BuildRequires: curl-devel +BuildRequires: expat-devel +%if %{with bundled_jsoncpp} +Provides: bundled(jsoncpp) +%else +BuildRequires: jsoncpp-devel +%endif +BuildRequires: libarchive-devel +BuildRequires: libuv-devel +%if %{with bundled_rhash} +Provides: bundled(rhash) +%else +BuildRequires: rhash-devel +%endif +BuildRequires: xz-devel +BuildRequires: zlib-devel +BuildRequires: vim-filesystem +%endif +%if %{with emacs} +BuildRequires: emacs +%endif +BuildRequires: openssl-devel +%{!?python3_pkgversion: %global python3_pkgversion 3} +BuildRequires: python%{python3_pkgversion}-devel +%if %{with gui} +BuildRequires: pkgconfig(Qt5Widgets) +BuildRequires: desktop-file-utils +%endif + +BuildRequires: pkgconfig(bash-completion) +%global bash_completionsdir %(pkg-config --variable=completionsdir bash-completion 2>/dev/null || echo '%{_datadir}/bash-completion/completions') + +%if %{without bootstrap} +BuildRequires: %{name}-rpm-macros +%endif +BuildRequires: make + +Requires: %{name}-data = %{version}-%{release} +Requires: %{name}-rpm-macros = %{version}-%{release} +Requires: %{name}-filesystem%{?_isa} = %{version}-%{release} +Requires: make + +Provides: %{name}%{major_version} = %{version}-%{release} +Provides: bundled(md5-deutsch) +Provides: bundled(kwsys) + +%description +CMake is used to control the software compilation process using simple +platform and compiler independent configuration files. CMake generates +native makefiles and workspaces that can be used in the compiler +environment of your choice. CMake is quite sophisticated: it is possible +to support complex environments requiring system configuration, preprocessor +generation, code generation, and template instantiation. + + +%package data +Summary: Common data-files for %{name} +Requires: %{name} = %{version}-%{release} +Requires: %{name}-filesystem = %{version}-%{release} +Requires: %{name}-rpm-macros = %{version}-%{release} +%if %{with emacs} +Requires: emacs-filesystem%{?_emacs_version: >= %{_emacs_version}} +%endif +Requires: vim-filesystem + +BuildArch: noarch + +%description data +This package contains common data-files for %{name}. + + +%package doc +Summary: Documentation for %{name} +BuildArch: noarch + +%description doc +This package contains documentation for %{name}. + + +%package filesystem +Summary: Directories used by CMake modules + +%description filesystem +This package owns all directories used by CMake modules. + + +%if %{with gui} +%package gui +Summary: Qt GUI for %{name} + +Requires: %{name}%{?_isa} = %{version}-%{release} +Requires: hicolor-icon-theme +Requires: shared-mime-info%{?_isa} + +%description gui +The %{name}-gui package contains the Qt based GUI for %{name}. +%endif + + +%package rpm-macros +Summary: Common RPM macros for %{name} +Requires: rpm + +BuildArch: noarch + +%description rpm-macros +This package contains common RPM macros for %{name}. + + +%prep +%autosetup -n %{name}-%{version} -p 1 + +echo '#!%{__python3}' > %{name}.prov +echo '#!%{__python3}' > %{name}.req +tail -n +2 %{SOURCE4} >> %{name}.prov +tail -n +2 %{SOURCE5} >> %{name}.req + +%build +%if 0%{?set_build_flags:1} +%{set_build_flags} +%else +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 ;} +%endif +SRCDIR="$(/usr/bin/pwd)" +mkdir %{_vpath_builddir} +pushd %{_vpath_builddir} +$SRCDIR/bootstrap --prefix=%{_prefix} \ + --datadir=/share/%{name} \ + --docdir=/share/doc/%{name} \ + --mandir=/share/man \ + --%{?with_bootstrap:no-}system-libs \ + --parallel="$(echo %{?_smp_mflags} | sed -e 's|-j||g')" \ +%if %{with bundled_rhash} + --no-system-librhash \ +%endif +%if %{with bundled_jsoncpp} + --no-system-jsoncpp \ +%endif +%if %{with sphinx} + --sphinx-man --sphinx-html \ +%else + --sphinx-build=%{_bindir}/false \ +%endif + --%{!?with_gui:no-}qt-gui \ + -- \ + -DCMAKE_C_FLAGS_RELEASE:STRING="-O2 -g -DNDEBUG" \ + -DCMAKE_CXX_FLAGS_RELEASE:STRING="-O2 -g -DNDEBUG" \ + -DCMAKE_Fortran_FLAGS_RELEASE:STRING="-O2 -g -DNDEBUG" \ + -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \ + -DCMAKE_INSTALL_DO_STRIP:BOOL=OFF +popd +%make_build -C %{_vpath_builddir} + + +%install +mkdir -p %{buildroot}%{_pkgdocdir} +%make_install -C %{_vpath_builddir} CMAKE_DOC_DIR=%{buildroot}%{_pkgdocdir} +find %{buildroot}%{_datadir}/%{name}/Modules -type f | xargs chmod -x +[ -n "$(find %{buildroot}%{_datadir}/%{name}/Modules -name \*.orig)" ] && + echo "Found .orig files in %{_datadir}/%{name}/Modules, rebase patches" && + exit 1 +%{!?name_suffix:for f in ccmake cmake cpack ctest; do ln -s $f %{buildroot}%{_bindir}/${f}%{major_version}; done} + +%if %{with emacs} +mkdir -p %{buildroot}%{_emacs_sitelispdir}/%{name} %{buildroot}%{_emacs_sitestartdir} +mv %{buildroot}%{_emacs_sitelispdir}/%{name}-mode.el %{buildroot}%{_emacs_sitelispdir}/%{name} +%{_emacs_bytecompile} %{buildroot}%{_emacs_sitelispdir}/%{name}/%{name}-mode.el +install -p -m 0644 %{SOURCE1} %{buildroot}%{_emacs_sitestartdir} +%else +rm -f %{buildroot}%{_emacs_sitelispdir} +%endif + +install -p -m0644 -D %{SOURCE2} %{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 %{SOURCE2} %{buildroot}%{rpm_macros_dir}/macros.%{name} +%if 0%{?_rpmconfigdir:1} +install -p -m0644 -D %{SOURCE3} %{buildroot}%{_prefix}/lib/rpm/fileattrs/%{name}.attr +install -p -m0755 -D %{name}.prov %{buildroot}%{_prefix}/lib/rpm/%{name}.prov +install -p -m0755 -D %{name}.req %{buildroot}%{_prefix}/lib/rpm/%{name}.req +%endif +mkdir -p %{buildroot}%{_libdir}/%{name} +find Source Utilities -type f -iname copy\* | while read f +do + fname=$(basename $f) + dir=$(dirname $f) + dname=$(basename $dir) + cp -p $f ./${fname}_${dname} +done +%if %{with sphinx} +mv %{buildroot}%{_docdir}/%{name}/html . +%endif +rm -rf %{buildroot}%{_docdir}/%{name} +mkdir -p %{buildroot}%{_pkgdocdir} +cp -pr %{buildroot}%{_datadir}/%{name}/Help %{buildroot}%{_pkgdocdir} +mv %{buildroot}%{_pkgdocdir}/Help %{buildroot}%{_pkgdocdir}/rst +%if %{with sphinx} +mv html %{buildroot}%{_pkgdocdir} +%endif + +%if %{with gui} +desktop-file-install --delete-original \ + --dir=%{buildroot}%{_datadir}/applications \ + %{buildroot}%{_datadir}/applications/%{name}-gui.desktop +%endif + +find %{buildroot}%{_datadir}/%{name} -type d | \ + sed -e 's!^%{buildroot}!%%dir "!g' -e 's!$!"!g' > data_dirs.mf +find %{buildroot}%{_datadir}/%{name} -type f | \ + sed -e 's!^%{buildroot}!"!g' -e 's!$!"!g' > data_files.mf +find %{buildroot}%{_libdir}/%{name} -type d | \ + sed -e 's!^%{buildroot}!%%dir "!g' -e 's!$!"!g' > lib_dirs.mf +find %{buildroot}%{_libdir}/%{name} -type f | \ + sed -e 's!^%{buildroot}!"!g' -e 's!$!"!g' > lib_files.mf +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 + +%if %{with test} +%check +pushd %{_vpath_builddir} +NO_TEST="CTestTestUpload" +NO_TEST="$NO_TEST|CustomCommand|CMakeLib.testCTestResourceAllocator" +NO_TEST="$NO_TEST|CMakeLib.testCTestResourceSpec|RunCMake.PositionIndependentCode" +%if %{with bootstrap} +NO_TEST="$NO_TEST|curl" +%endif +bin/ctest%{?name_suffix} %{?_smp_mflags} -V -E "$NO_TEST" --output-on-failure +popd +%endif + +%files -f lib_files.mf +%doc %dir %{_pkgdocdir} +%license Copyright.txt* +%license COPYING* +%if %{with sphinx} +%{_mandir}/man1/c%{name}.1.* +%{_mandir}/man1/%{name}.1.* +%{_mandir}/man1/cpack%{?name_suffix}.1.* +%{_mandir}/man1/ctest%{?name_suffix}.1.* +%{_mandir}/man7/*.7.* +%endif + + +%files data -f data_files.mf +%{_datadir}/aclocal/%{name}.m4 +%{bash_completionsdir}/c* +%if %{with emacs} +%{_emacs_sitelispdir}/%{name} +%{_emacs_sitestartdir}/%{name}-init.el +%endif +%{vimfiles_root}/indent/%{name}.vim +%{vimfiles_root}/syntax/%{name}.vim + +%files doc +%{?_licensedir:%license %{_datadir}/licenses/%{name}*} +%doc %{_pkgdocdir} + +%files filesystem -f data_dirs.mf -f lib_dirs.mf + +%if %{with gui} +%files gui +%{_bindir}/%{name}-gui +%{_datadir}/applications/%{name}-gui.desktop +%{_datadir}/mime/packages +%{_datadir}/icons/hicolor/*/apps/CMake%{?name_suffix}Setup.png +%if %{with sphinx} +%{_mandir}/man1/%{name}-gui.1.* +%endif +%endif + +%files rpm-macros +%{rpm_macros_dir}/macros.%{name} +%if 0%{?_rpmconfigdir:1} +%{_rpmconfigdir}/fileattrs/%{name}.attr +%{_rpmconfigdir}/%{name}.prov +%{_rpmconfigdir}/%{name}.req +%endif + +%changelog +* Wed Mar 9 2022 forrest_ly - 3.22.3-1 +- Init for Anolis OS 23 diff --git a/macros.cmake b/macros.cmake new file mode 100644 index 0000000000000000000000000000000000000000..54598ee26c540914814682b6ef1e77d96ed4fa00 --- /dev/null +++ b/macros.cmake @@ -0,0 +1,62 @@ +# +# 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 +# - 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 \ +%if 0%{?set_build_flags:1} \ + %set_build_flags \ +%else \ + 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 ;} \ +%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" \\\ + -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} \\\ + -DSHARE_INSTALL_PREFIX:PATH=%{_datadir} \\\ +%if "%{?_lib}" == "lib64" \ + %{?_cmake_lib_suffix64} \\\ +%endif \ + %{?_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 %{**}