diff options
| author | CoprDistGit <infra@openeuler.org> | 2023-07-06 09:22:00 +0000 |
|---|---|---|
| committer | CoprDistGit <infra@openeuler.org> | 2023-07-06 09:22:00 +0000 |
| commit | d82cc6b3a7a76e3071e5315c2f11023db18ea1b9 (patch) | |
| tree | 259fabde9d7fcbbef7b290af1626dedec1521855 | |
| parent | e71b73575e2983de023725d74912afb400ffbb11 (diff) | |
automatic import of cmake
| -rw-r--r-- | cmake-findruby.patch | 22 | ||||
| -rw-r--r-- | cmake-init.el | 9 | ||||
| -rw-r--r-- | cmake-mingw-dl.patch | 18 | ||||
| -rw-r--r-- | cmake.attr | 3 | ||||
| -rw-r--r-- | cmake.prov | 75 | ||||
| -rw-r--r-- | cmake.req | 70 | ||||
| -rw-r--r-- | cmake.spec | 30 | ||||
| -rw-r--r-- | macros.cmake | 36 |
8 files changed, 248 insertions, 15 deletions
diff --git a/cmake-findruby.patch b/cmake-findruby.patch new file mode 100644 index 0000000..72a8b25 --- /dev/null +++ b/cmake-findruby.patch @@ -0,0 +1,22 @@ +Index: cmake-3.23.0-rc2/Modules/FindRuby.cmake +=================================================================== +--- cmake-3.23.0-rc2.orig/Modules/FindRuby.cmake ++++ cmake-3.23.0-rc2/Modules/FindRuby.cmake +@@ -315,14 +315,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 0000000..a5e0e2e --- /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 0000000..9934788 --- /dev/null +++ b/cmake-mingw-dl.patch @@ -0,0 +1,18 @@ +Index: cmake-3.23.0-rc2/Modules/Platform/Windows-GNU.cmake +=================================================================== +--- cmake-3.23.0-rc2.orig/Modules/Platform/Windows-GNU.cmake ++++ cmake-3.23.0-rc2/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 0000000..83f3f1a --- /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 0000000..f569c23 --- /dev/null +++ b/cmake.prov @@ -0,0 +1,75 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- +# +# Copyright (C) 2015 Daniel Vrátil <dvratil@redhat.com> +# Copyright (C) 2017 Daniel Vrátil <dvratil@fedoraproject.org> +# +# +# 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: + print("cmake(%s) = %s" % (cmakeModule, version)) + else: + print("cmake(%s)" % cmakeModule) + + + 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>) + 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 0000000..2a58ca3 --- /dev/null +++ b/cmake.req @@ -0,0 +1,70 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- +# +# Copyright (C) 2017 Björn Esser <besser82@fedoraproject.org> +# +# based on cmake.prov, which is +# Copyright (C) 2015 Daniel Vrátil <dvratil@redhat.com> +# Copyright (C) 2017 Daniel Vrátil <dvratil@fedoraproject.org> +# +# +# 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() @@ -15,17 +15,17 @@ Release: 1 Summary: Cross-platform make system License: BSD and MIT and zlib URL: http://www.cmake.org -Source0: https://cmake.org/files/v3.26/cmake-%{version}.tar.gz -#Source1: cmake-init.el -#Source2: macros.cmake -#Source3: cmake.attr -#Source4: cmake.prov -#Source5: cmake.req -#Patch0: cmake-findruby.patch +Source0: https://www.cmake.org/files/v3.26/cmake-%{version}.tar.gz +Source1: cmake-init.el +Source2: macros.cmake +Source3: cmake.attr +Source4: cmake.prov +Source5: cmake.req +Patch0: cmake-findruby.patch #Patch1: cmake-fedora-flag_release.patch -#Patch2: cmake-mingw-dl.patch +Patch2: cmake-mingw-dl.patch %ifarch sw_64 -#Patch3: cmake-3.22.0-sw.patch +Patch3: cmake-3.22.0-sw.patch %endif BuildRequires: coreutils findutils gcc-c++ gcc-gfortran sed @@ -103,8 +103,8 @@ Documentation for cmake. %prep %autosetup -n cmake-%{version}%{?versuf} -p 1 -#sed '1c #!%{__python3}' %{SOURCE4} > cmake.prov -#sed '1c #!%{__python3}' %{SOURCE5} > cmake.req +sed '1c #!%{__python3}' %{SOURCE4} > cmake.prov +sed '1c #!%{__python3}' %{SOURCE5} > cmake.req %build export CFLAGS=`echo %{optflags} | sed 's/-g\b/-s/g'` @@ -143,11 +143,11 @@ install -d %{buildroot}%{_emacs_sitelispdir}/cmake install -p -m 0644 Auxiliary/cmake-mode.el %{buildroot}%{_emacs_sitelispdir}/cmake/cmake-mode.el %{_emacs_bytecompile} %{buildroot}%{_emacs_sitelispdir}/cmake/cmake-mode.el install -d %{buildroot}%{_emacs_sitestartdir} -#install -p -m 0644 %SOURCE1 %{buildroot}%{_emacs_sitestartdir} -#install -p -m0644 -D %{SOURCE2} %{buildroot}%{rpm_macros_dir}/macros.cmake +install -p -m 0644 %SOURCE1 %{buildroot}%{_emacs_sitestartdir} +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 +touch -r %{SOURCE2} %{buildroot}%{rpm_macros_dir}/macros.cmake +install -p -m0644 -D %{SOURCE3} %{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 diff --git a/macros.cmake b/macros.cmake new file mode 100644 index 0000000..1768aab --- /dev/null +++ b/macros.cmake @@ -0,0 +1,36 @@ +# +# Macros for cmake +# +%_cmake_lib_suffix64 -DLIB_SUFFIX=64 +%_cmake_skip_rpath -DCMAKE_SKIP_RPATH:BOOL=ON +%_cmake_version @@CMAKE_VERSION@@ +%__cmake /usr/bin/cmake + +# - 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 +# - 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 \ + -DBUILD_SHARED_LIBS:BOOL=ON + +%cmake@@CMAKE_MAJOR_VERSION@@ %cmake |
