Skip to content

Conversation

haampie
Copy link
Contributor

@haampie haampie commented Apr 13, 2023

cmake_minimum_required(VERSION 2.x) has the effect that any recent CMake runs with default settings that were considered sensible a decade ago.

Instead, use cmake_minimum_required(VERSION 2.x...3.y) so that newer CMake uses modern defaults for policies, without dropping CMake 2.x support.

One such policy that I need for example is CMP0042, which makes CMake output @rpath/liblz4.dylib as install name on macOS, so that packages linking to it register @rpath/liblz4.dylib as a load command, so that rpaths will be considered to locate it. Without it, dependents typically fail at runtime and cannot locate the library if it's in a non-system dir.

cmake_minimum_required(VERSION 2.x) has the effect that recent cmake 3.x has the defaults that were considered sensible a decade ago.

Instead, use `cmake_minimum_required(VERSION 2.x..3.y)` so that newer cmake uses modern defaults for policies, without dropping cmake 2.x support.
@haampie
Copy link
Contributor Author

haampie commented Apr 13, 2023

ping @nemequ

@Cyan4973
Copy link
Member

Cyan4973 commented Apr 13, 2023

Note :
the 2.8.12 minimum version requirement is old policy, dated from the time when CMakeLists.txt was created, and multiple active distributions used to rely on this version of cmake.

By now, things have moved on, and we could update the minimum version, up to a maximum of 3.5.1 if need be.

It's just that there is no point in reducing compatibility (by increasing the minimum version requirement) if there is no benefit in exchange, and so far, no one has been able to articulate what is gained by updating the minimum version to something more recent.
But this can be debated.

@haampie
Copy link
Contributor Author

haampie commented Apr 21, 2023

Feel free to update the PR accordingly. This is more of an issue promoted to a actionable change :p

@Cyan4973
Copy link
Member

I think cmake has started rolling some warning messages on very recent versions of cmake,
which states, in substance, that some future version of cmake will stop supporting minimum versions < 3.5.

Consequently, I think this is the minimum version this PR should jump to.
Updating the minimum version to v3.5 would be enough to fix CMP0042 support.

I prefer a single minimum version number, because otherwise, the CMakeLists.txt script will behave differently depending on local versions, increasing support matrix complexity.

Copy link
Member

@Cyan4973 Cyan4973 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change minimum to 3.5

@haampie haampie changed the title Set CMake policy max to something recent Set CMake minimum requirement to 3.5 Aug 15, 2023
@haampie
Copy link
Contributor Author

haampie commented Aug 15, 2023

Done

if("${CMAKE_VERSION}" VERSION_LESS "3.0")
project(LZ4 C)
else()
cmake_policy (SET CMP0048 NEW)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question : is it now useless to specify this line ?
cmake_policy (SET CMP0048 NEW)

Copy link
Contributor Author

@haampie haampie Aug 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the policy is from 3.0 and with minimum required >= 3.0 it's automatically NEW.

The policies are always such that new cmake behaves the same as the "minimum required" cmake version.

@Cyan4973
Copy link
Member

Thanks @haampie

@Cyan4973 Cyan4973 merged commit e130e71 into lz4:dev Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants