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

Igor Munkin imun at tarantool.org
Wed Jan 20 21:19:47 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 minimal required version in build documentation

This commit updates the CMake minimal 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 minimal
required version is 3.1 since this commit. See the commit message for
more info.
---
 debian/control     |  9 ++++++++-
 rpm/tarantool.spec | 33 ++++++++++++++++++++++++++++++---
 2 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/debian/control b/debian/control
index 38d0ba731..0741e91f8 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 it 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 aae60f8dc..4167ca480 100644
--- a/rpm/tarantool.spec
+++ b/rpm/tarantool.spec
@@ -5,7 +5,28 @@
 %bcond_with systemd
 %endif
 
-BuildRequires: cmake >= 2.8
+# XXX: There is an old CMake (2.8.12) provided by cmake package in
+# main CentOS repositories for distributions older than CentOS 7
+# (inclusively). At the same time, there is a newer package cmake3
+# providing CMake 3+ from EPEL repository. Ergo, one need to use
+# cmake3 package to build Tarantool on old systems.
+# FIXME: Make the condition simpler after CentOS 6 is purged from
+# Tarantool infrastructure.
+%define use_cmake3 %{?rhel:%{rhel}}%{!?rhel:9999} <= 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 6 and RHEL/CentOS 7
+# proceed to 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)
 # RHEL 6 requires devtoolset
@@ -115,7 +135,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
@@ -147,7 +167,14 @@ C and Lua/C modules.
 
 %build
 # RHBZ #1301720: SYSCONFDIR an LOCALSTATEDIR must be specified explicitly
-%cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo \
+# 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
+       . -DCMAKE_BUILD_TYPE=RelWithDebInfo \
          -DCMAKE_INSTALL_LOCALSTATEDIR:PATH=%{_localstatedir} \
          -DCMAKE_INSTALL_SYSCONFDIR:PATH=%{_sysconfdir} \
 %if %{with backtrace}
-- 
2.25.0



More information about the Tarantool-patches mailing list