[CMake] Advice on converting legacy project to modern CMake

Alan W. Irwin irwin at beluga.phys.uvic.ca
Mon Aug 7 16:53:41 EDT 2017


On 2017-08-07 11:35-0000 Björn Blissing wrote:

> 1. Which version if CMake should I target? I.e. Which version should
I require in my cmake_minimum_required() statement?

I would suggest either

cmake_minimum_required(VERSION 3.6.2 FATAL_ERROR)

or

cmake_minimum_required(VERSION 3.7.2 FATAL_ERROR)

depending on whether the Cygwin platform (currently only making
3.6.2 available) is important to your users or not.

Cygwin is important to PLplot so we recently adopted 3.6.2 as the
minimum version choice as the compromise between two goals:

(1) We wanted to maximize the version of policies
(which are set by cmake_minimum_required) since the latest
version of policies typically make a lot of sense to us
in terms of eliminating subtle build-system bugs.

(2) We wanted to minimize the minimum version to maximize the
percentage of our users who will have that minimum version or higher
available from the official binary CMake version that is supplied by
their software distribution.

3.6.2 currently satisfies goal (1) reasonably well because it is not too far
behind the latest version 3.9.0 in terms of policy.

3.6.2 also satisfies goal (2) reasonably well.  The major exception
here is the so-called Linux "enterprise-class" distributions who go
out of their way to **only** support old versions of Linux software
because their customers somehow feel more comfortable with that.  For
example, as far as I can tell from google searches, it looks like
RedHat Linux Enterprise versions still only support CMake-2.

Which leads to a question I have for the Kitware types here.  What
should I suggest to my Linux enterprise distribution users? Can they
simply download and use the latest Linux binary version of CMake that
is distributed by Kitware or are there library version
incompatibilities that make that option non-viable? Alternatively, if
such users want to build modern CMake for themselves can they do that
or do system library incompatibilities stop them in that case as well?

If we ignore the "enterprise-class" users, then Debian stable supports
3.7.2.  Debian tends to be a bit of a late adopter so as far as I know
every other non-enterprise Linux distribution and the various *BSD
distributions supports that version of CMake or higher. And I know
that is also true for MinGW-w64/MSYS2 and the Mac OS X distributions
(Homebrew, MacPorts, and Fink).  So I plan to bump the minimum version
we support to 3.7.2 as soon as Cygwin (currently only supporting
3.6.2) falls into line with the rest.

I haven't mentioned the Windows MSVC platform here yet which is also
important to us.  But those users are given no official choice of
CMake as a binary download so they likely take another viable choice
which is to download, install, and use a Kitware binary version of
CMake for Windows, and as far as I know all released versions of
CMake-3 (as well as CMake-2) are available that way.

In any case, for whatever minimum version of CMake you adopt, you
should test your build system for that version as well as at least the
latest CMake version.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list