[Tarantool-patches] [PATCH luajit 2/2][v2] cmake: fix warning about minimum required version

Sergey Bronnikov estetus at gmail.com
Tue Jun 18 15:00:09 MSK 2024


From: Sergey Bronnikov <sergeyb at tarantool.org>

Since CMake 3.27 compatibility with versions of CMake older than
3.5 is deprecated [1]. CMake produces annoying warning on
configuration stage:

| CMake Deprecation Warning at src/CMakeLists.txt:7 (cmake_minimum_required):
|  Compatibility with CMake < 3.5 will be removed from a future version of
|  CMake.

We cannot bump a minimum required CMake version without bumping
it in the Tarantool build system. However, we can set
a <policy_max> (introduced in CMake 3.12, see [1]) and suppress
a warning. <policy_max> means that this CMake version is known to
work properly and will not result in any build errors rightaway
for higher versions.

Note, that a current CMake minimum required version in Tarantool
is equal to 2.8, but <policy_max> is introduced in CMake 3.12 [1].
However, according to [1] it is not a problem, because if CMake is
"older than 3.12, the extra ... dots will be seen as version
component separators, resulting in the ...<max> part being ignored
and preserving the pre-3.12 behavior of basing policies on <min>".

<policy_max> is set to 3.18 because compatibility with versions
of CMake older than 2.8.12 is deprecated. Calls to
cmake_minimum_required(VERSION) that do not specify at
least 2.8.12 as their policy version (optionally via ...<max>)
will produce a deprecation warning in CMake 3.19 and above [2].
Compatibility with 2.8.12 is needed for CMP0002 [3], see
commit 049e296ee114 ("test: run LuaJIT tests via CMake").

1. https://cmake.org/cmake/help/latest/command/cmake_minimum_required.html
2. https://cmake.org/cmake/help/latest/command/cmake_minimum_required.html#policy-settings
3. https://cmake.org/cmake/help/latest/policy/CMP0002.html
---
 CMakeLists.txt | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 09fa172c..f12282c6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,16 @@
 # --- Initial setup ------------------------------------------------------------
 
 # See the rationale below (near LUAJIT_TEST_BINARY variable).
-cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
+# <policy_max> is set to 3.18 because compatibility with versions
+# of CMake older than 2.8.12 is deprecated. Calls to
+# cmake_minimum_required(VERSION) that do not specify at
+# least 2.8.12 as their policy version (optionally via ...<max>)
+# will produce a deprecation warning in CMake 3.19 and above [1].
+# Compatibility with 2.8.12 is needed for CMP0002 [2].
+#
+# [1] https://cmake.org/cmake/help/latest/command/cmake_minimum_required.html#policy-settings
+# [2] https://cmake.org/cmake/help/latest/policy/CMP0002.html
+cmake_minimum_required(VERSION 3.1...3.18 FATAL_ERROR)
 project(LuaJIT C)
 
 # XXX: Originally CMake machinery is introduced to make LuaJIT
-- 
2.34.1



More information about the Tarantool-patches mailing list