MantisBT - CMake
View Issue Details
0012458CMakeCMakepublic2011-09-14 19:272012-04-02 10:10
Stephen Kelly 
David Cole 
normalminoralways
closedno change required 
CMake 2.8.5 
CMake 2.8.7CMake 2.8.7 
0012458: cmake_minimum_required clears policies
The attached project contains the line

cmake_policy(SET CMP0017 NEW)

but also warns about the policy not being set:

$ cmake ..
CMake Warning (dev) at /usr/share/cmake-2.8/Modules/FeatureSummary.cmake:112 (INCLUDE):
  File /usr/share/cmake-2.8/Modules/FeatureSummary.cmake includes
  /home/stephen/dev/src/playground/cmakebugs/CMakeParseArguments.cmake (found
  via CMAKE_MODULE_PATH) which shadows
  /usr/share/cmake-2.8/Modules/CMakeParseArguments.cmake. This may cause
  errors later on .

  Policy CMP0017 is not set: Prefer files from the CMake module directory
  when including from there. Run "cmake --help-policy CMP0017" for policy
  details. Use the cmake_policy command to set the policy and suppress this
  warning.
Call Stack (most recent call first):
  sub1/CMakeLists.txt:4 (include)
This warning is for project developers. Use -Wno-dev to suppress it.

-- Configuring done
-- Generating done
-- Build files have been written to: /home/stephen/dev/src/playground/cmakebugs/build

The warning does not appear if the cmake_minimum_required line in sub1/CMakeLists.txt is removed.

The documentation of cmake_minimum_required notes that the policy is implicitly set to the cmake version specified. However I still found it surprising that it clears all existing policies.

If this is intentional, it should probably be in the cmake_minimum_required documentation.
No tags attached.
gz policybug.tar.gz (378) 2011-09-14 19:27
https://public.kitware.com/Bug/file/4052/policybug.tar.gz
Issue History
2011-09-14 19:27Stephen KellyNew Issue
2011-09-14 19:27Stephen KellyFile Added: policybug.tar.gz
2011-09-14 22:29David ColeAssigned To => David Cole
2011-09-14 22:29David ColeStatusnew => assigned
2011-09-14 22:31David ColeNote Added: 0027425
2011-10-25 23:07David ColeNote Added: 0027646
2011-10-27 00:05David ColeTarget Version => CMake 2.8.7
2011-11-17 16:26David ColeNote Added: 0027817
2011-11-17 16:26David ColeStatusassigned => resolved
2011-11-17 16:26David ColeFixed in Version => CMake 2.8.7
2011-11-17 16:26David ColeResolutionopen => no change required
2012-04-02 10:10David ColeNote Added: 0029043
2012-04-02 10:10David ColeStatusresolved => closed

Notes
(0027425)
David Cole   
2011-09-14 22:31   
This behavior is completely intentional, and we will not be changing it. I'll take a look at the documentation to see if I can clarify it, but this is not urgent... We won't hold the 2.8.6 release for a fix on this, but we'll get it in for next time.
(0027646)
David Cole   
2011-10-25 23:07   
The documentation of cmake_minimum_required states:

-----
When a version higher than 2.4 is specified the command implicitly invokes

         cmake_policy(VERSION major[.minor[.patch[.tweak]]])
-----

So, naturally, you have to look at the documentation of cmake_policy(VERSION ...) to understand what happens there. And that documentation is quite explicit about setting all policies as of the VERSION number to NEW, and later policies to *unset* (unless variable CMAKE_POLICY_DEFAULT_CMP<NNNN> sets a default)

Not sure how to make it more clear without repeating ourselves...

Suggestions for how to make it more clear would be welcome.

If no reasonable suggestions arrive in this issue in the next week or so, I'll resolve it as "no change required..."
(0027817)
David Cole   
2011-11-17 16:26   
After more than three weeks with no additional comments, closing as "no change required," as promised. If anyone has further suggestions for clarifying the documentation here, please feel free to re-open.
(0029043)
David Cole   
2012-04-02 10:10   
Closing resolved issues that have not been updated in more than 4 months.