[Tarantool-patches] [PATCH v2 2/2] build: update CMake minimum version to 3.1

Igor Munkin imun at tarantool.org
Mon Jan 25 22:14:43 MSK 2021


In scope of implementing self-sufficient testing environment LuaJIT
build system is partially ported to CMake. While integrating the new
build system with Tarantool it was found (on practice of course) that
using generator expressions[1] in target DEPENDS section is introduced
only in CMake 3.1[2]. This CMake feature is used to pass so called
"LuaJIT binary" to be used in LuaJIT tests, so one can run the same
testing machinery with both Tarantool and LuaJIT with no changes in it.

[1]: https://cmake.org/cmake/help/v3.1/manual/cmake-generator-expressions.7.html
[2]: https://cmake.org/cmake/help/latest/release/3.1.html#commands

Relates to #4862

Signed-off-by: Igor Munkin <imun at tarantool.org>

@TarantoolBot document
Title: Update CMake minimum required version in build documentation

This commit updates the CMake minimum required version to be used in
Tarantool build infrastructure. However, one can build Tarantool from
sources and the required toolchain list should be updated. CMake minimum
required version is 3.1 since this commit. See the commit message for
more info.

Signed-off-by: Igor Munkin <imun at tarantool.org>
---
 debian/control     |  9 ++++++++-
 rpm/tarantool.spec | 30 +++++++++++++++++++++++++++---
 2 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/debian/control b/debian/control
index 8be2e9d01..ce810ee67 100644
--- a/debian/control
+++ b/debian/control
@@ -5,7 +5,14 @@ Uploaders: Dmitry E. Oboukhov <unera at debian.org>
 Build-Depends: cdbs (>= 0.4.100), debhelper (>= 9), dpkg-dev (>= 1.16.1~),
 # Enable systemd for Debian Jessie+ and Ubuntu Wily+
  debhelper (>= 9.20160709) | dh-systemd (>= 1.22) | sysvinit (<< 2.88dsf-59) | upstart (<< 1.13),
- cmake,
+# XXX: This is a tiny hack to support Tarantool build on the old
+# distributions (e.g. Ubuntu Trusty Tahr) providing CMake 3+ via
+# cmake3 package that conflicts and replaces cmake package (that
+# provides CMake 2.18). Alternatives resolution order allows to
+# make package manager seek for cmake3 package at first and use it
+# if found or fallback to cmake package (that provides CMake 3+
+# for modern distributions) otherwise.
+ cmake3 (>= 3.1) | cmake (>= 3.1),
  libreadline-dev,
  libncurses5-dev,
  libssl-dev,
diff --git a/rpm/tarantool.spec b/rpm/tarantool.spec
index 8ba14d4d0..ffd161862 100644
--- a/rpm/tarantool.spec
+++ b/rpm/tarantool.spec
@@ -5,7 +5,24 @@
 %bcond_with systemd
 %endif
 
-BuildRequires: cmake >= 2.8
+# XXX: There is an old CMake (2.8.12) provided by cmake package in
+# main CentOS 7 repositories. At the same time, there is a newer
+# package cmake3 providing CMake 3+ from EPEL repository. So, one
+# need to use cmake3 package to build Tarantool on old systems.
+%define use_cmake3 0%{?rhel} == 7
+
+%if %use_cmake3
+# XXX: Unfortunately there is no way to make rpmbuild install and
+# enable EPEL repository prior to the build step. However, the
+# requirement below obligues user to enable EPEL by himself,
+# otherwise this dependency is left unmet. If there are any issues
+# with building an RPM package on RHEL/CentOS 7 read the docs:
+# https://www.tarantool.io/en/doc/latest/dev_guide/building_from_source/
+BuildRequires: cmake3 >= 3.1
+%else
+BuildRequires: cmake >= 3.1
+%endif
+
 BuildRequires: make
 %if (0%{?fedora} >= 22 || 0%{?rhel} >= 7 || 0%{?sle_version} >= 1500)
 BuildRequires: gcc >= 4.5
@@ -115,7 +132,7 @@ Requires: openssl
 # RHEL <= 7 doesn't support Recommends:
 Recommends: tarantool-devel
 Recommends: git-core
-Recommends: cmake >= 2.8
+Recommends: cmake >= 3.1
 Recommends: make
 Recommends: gcc >= 4.5
 Recommends: gcc-c++ >= 4.5
@@ -154,7 +171,14 @@ C and Lua/C modules.
 # 2. -DENABLE_LTO=ON
 #    because for now LTO flags are set in CC/LD flags by default:
 #      '-flto=auto -ffat-lto-objects'
-%cmake -B . \
+# XXX: KISS, please. I can play with RPM macros to redefine cmake
+# macro for cmake3 usage, but it totally doesn't worth it.
+%if %use_cmake3
+%cmake3 \
+%else
+%cmake \
+%endif
+       -B . \
          -DCMAKE_BUILD_TYPE=RelWithDebInfo \
          -DCMAKE_INSTALL_LOCALSTATEDIR:PATH=%{_localstatedir} \
          -DCMAKE_INSTALL_SYSCONFDIR:PATH=%{_sysconfdir} \
-- 
2.25.0



More information about the Tarantool-patches mailing list