[cmake-developers] different behavior of cmake_minimum_required(3.0) and 3.1
Rolf Eike Beer
eike at sf-mail.de
Tue Mar 19 02:42:28 EDT 2019
Am 2019-03-18 14:45, schrieb Brad King:
> 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.
The starting point was 2.8.11, I have not bothered to change the loop
afterwards.
> 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.
Good idea.
> -------------------------------------------------------------
>
> 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.
This is not the case, I have changed that and it did not help.
> 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.
I'll look into this. The problem here is that this IIRC breaks with new
CMake and old Qt version where this would process generated files twice.
Eike
More information about the cmake-developers
mailing list