[CMake] CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR) and cmake_policy(VERSION 2.6.0) not working correctly for 2.6.2

Alan W. Irwin irwin at beluga.phys.uvic.ca
Sun Feb 1 12:50:31 EST 2009


On 2009-02-01 09:03-0800 Alan W. Irwin wrote:

> According to the documentation of 2.6.2, policies CMP0008 and CMP0009
> were introduced after 2.6.0.  Also, according to that documentation,
> cmake_policy(VERSION 2.6.0) should set those policies to OLD and warn about
> that.
>
> I use
>
> CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)
>
> according to the documentation that sets
>
> cmake_policy(VERSION 2.6.0)
>
> by default.  This documented behaviour seems quite logical and useful so
> that users can use a variety of CMake versions above 2.6.0 and get the
> same 2.6.0 policies.
>
> However, I could see no such warning messages concerning policies CMP0008 and
> CMP0009 even with -Wdev (and even if I use cmake_policy(VERSION 2.6.0)
> explicitly).  I then investigated further with
>
> foreach(policy RANGE 0 9)
>  if(POLICY CMP000${policy})
>      message(STATUS "Policy ${policy} is ON")
>  else(POLICY CMP000${policy})
>      message(STATUS "Policy ${policy} is OFF")
>  endif(POLICY CMP000${policy})
> endforeach(policy RANGE 0 9)
>
> and obtained
>
> -- Policy 0 is ON
> -- Policy 1 is ON
> -- Policy 2 is ON
> -- Policy 3 is ON
> -- Policy 4 is ON
> -- Policy 5 is ON
> -- Policy 6 is ON
> -- Policy 7 is ON
> -- Policy 8 is ON
> -- Policy 9 is ON
>
> I am pretty sure the ON result for policies CMP0008 and CMP0009 for
>
> CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)
>
> must be a bug in 2.6.2.

Oops!  That test simply asked if a policy exists.  So that test is ambiguous
at best.  Here is an improved test and results:

foreach(policy RANGE 0 9)
   cmake_policy(GET CMP000${policy} policy_result)
   message(STATUS "Policy CMP000${policy} is ${policy_result}")
endforeach(policy RANGE 0 9)

-- Policy CMP0000 is NEW
-- Policy CMP0001 is NEW
-- Policy CMP0002 is NEW
-- Policy CMP0003 is NEW
-- Policy CMP0004 is NEW
-- Policy CMP0005 is NEW
-- Policy CMP0006 is NEW
-- Policy CMP0007 is NEW
-- Policy CMP0008 is 
-- Policy CMP0009 is

So from these results (and if you can trust the documentation of
cmake_policy(GET ...)) it appears CMP0008 and CMP0009 are not set.  Shouldn't
those be set to OFF with a warning (i.e., the documented behaviour) when

CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)

is used?

If a policy is undefined as for CMP0008 and CMP0009 for 2.6.2 what does that
mean? Is that the same as OLD (or NEW) or does the policy implementation
have buggy/unknown behaviour under these circumstances?

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); PLplot scientific plotting software
package (plplot.org); 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