[cmake-developers] different behavior of cmake_minimum_required(3.0) and 3.1

Alan W. Irwin Alan.W.Irwin1234 at gmail.com
Fri Mar 15 23:02:20 EDT 2019


On 2019-03-15 23:10+0100 Rolf Eike Beer wrote:

> Out of boredom I'm hacking a bit around in the build system of Subsurface
> (https://github.com/Subsurface-divelog/subsurface). One of the things I'm
> looking to is requiring a newer CMake version. And now something strange
> happens:
>
> The original code:
> cmake_minimum_required(VERSION 2.8.11)
>
> This still works:
> cmake_minimum_required(VERSION 3.0)
>
> like this:
>
> -- Found PkgConfig: /usr/bin/pkg-config (found version "0.26")
> -- Checking for module 'libxml-2.0'
> --   Found libxml-2.0, version 2.9.4
> -- Checking for module 'sqlite3'
> --   Found sqlite3, version 3.20.1
> -- Checking for module 'libxslt'
> --   Found libxslt, version 1.1.29
> -- Checking for module 'libzip'
> --   Found libzip, version 1.1.3
>
>
> And this breaks:
> cmake_minimum_required(VERSION 3.1)
>
> like this:
>
> -- Found PkgConfig: /usr/bin/pkg-config (found version "0.26")
> -- Checking for module 'libxml-2.0'
> --   Found libxml-2.0, version 2.9.1
> -- Checking for module 'sqlite3'
> --   Found sqlite3, version 3.8.2
> -- Checking for module 'libxslt'
> --   Found libxslt, version 1.1.28
> -- Checking for module 'libzip'
> --   No package 'libzip' found
>
> I suspected it was a policy thing, so I tried this:
>
> foreach(_p RANGE 21 54)
>       cmake_policy(SET CMP00${_p} OLD)
> endforeach()
>
> Does not change anything.
>
> Build logs can be found here for 3.0:
> https://api.travis-ci.org/v3/job/506938155/log.txt
>
> And for 3.1:
> https://api.travis-ci.org/v3/job/506849909/log.txt
>
> It's a CMake 3.8.2 actually, which can be found in the mxe tarballs (look in
> the logs, IIRC it's the first one).
>
> Has anyone an idea what's happening there? And even more important: how to get
> it fixed? The maximum version the requirement can be raised to is 3.5.1 for
> the moment because of the supported Ubuntu versions (16.04+).

Hi Eike:

Since you appear to be running 3.8.2 in both cases, then the default
policy change difference between cmake_minimum_required(VERSION 3.0)
and cmake_minimum_required(VERSION 3.1) should be the only difference
between the two results.  So you appear to be left with (i)
cmake_minimum_required is not implemented as documented (i.e., there
is more going on then just a policy change for CMake 3.8.2), (ii)
there is some typo in how you changed policies for 
cmake_minimum_required(VERSION 3.1) to be effectively the same as the
default policies for cmake_minimum_required(VERSION 3.0), or (iii)
there is absolutely no explanation for what you have found.  :-)

However, if it were me I would simply forget about getting to the
bottom of this mystery for cmake_minimum_required(VERSION 3.1) since
that is a really an old set of policies.  Instead, I suggest you move
on to the more modern set of policies associated with
cmake_minimum_required(VERSION 3.5.1) to see whether you have the same
trouble in that case for a range of CMake versions (including 3.8.2,
just in case there is a specific bug in that version) from 3.5.1 to
the latest version.

Alan
__________________________
Alan W. Irwin

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-developers mailing list