[cmake-developers] different behavior of cmake_minimum_required(3.0) and 3.1
Brad King
brad.king at kitware.com
Mon Mar 18 09:45:15 EDT 2019
On 3/15/19 6:10 PM, Rolf Eike Beer wrote:
> I suspected it was a policy thing, so I tried this:
>
> foreach(_p RANGE 21 54)
> cmake_policy(SET CMP00${_p} OLD)
> endforeach()
Only policies 51-54 were added between 3.0 and 3.1. I suggest
testing with
cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0051 NEW)
cmake_policy(SET CMP0052 NEW)
cmake_policy(SET CMP0053 NEW)
cmake_policy(SET CMP0054 NEW)
and then trying different combinations. My guess is CMP0054.
-------------------------------------------------------------
While looking at the source of that project, I noticed that
both `CMakeLists.txt` and `smtk-import/CMakeLists.txt` call
the `project()` command before `cmake_minimum_required()`.
The other order is preferred:
cmake_minimum_required(VERSION 2.8.11)
project(Subsurface)
because there are policies that affect project()'s behavior.
This order preference is documented by both commands.
I also noticed this code:
```
# don't process generated files - this is new in 3.10
if (POLICY CMP0071)
cmake_policy(SET CMP0071 OLD)
endif()
```
The cmake-policies(7) manual states that a policy should only
be set to OLD to silence warnings in frozen code bases or in
short-term circumstances.
The proper way to deal with CMP0071 is to set it to NEW
and set the `SKIP_AUTO*` properties on the sources that should
not be processed.
-Brad
More information about the cmake-developers
mailing list