Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cmake] [c++] require CMake 3.18+ #6260

Merged
merged 2 commits into from
Jan 9, 2024
Merged

[cmake] [c++] require CMake 3.18+ #6260

merged 2 commits into from
Jan 9, 2024

Conversation

jameslamb
Copy link
Collaborator

@jameslamb jameslamb commented Jan 8, 2024

Fixes #5642.

Might help with the following:

Proposes the following:

  • moving this project's minimum CMake version up to v3.18
  • removing CMake version ranges from docs

Benefits of this change

This should reduce the risk of build failures with newer compilers, operating systems, architectures.

I'm especially hoping it'll help with M1/M2/M3 macOS support and supporting newer versions of CUDA.

Per the CMake docs (link):

The cmake_minimum_required(VERSION) command implicitly invokes the cmake_policy(VERSION) command to specify that the current project code is written for the given range of CMake versions. ... All policies introduced in later versions will be unset. This effectively requests behavior preferred as of a given CMake version and tells newer CMake versions to warn about their new policies.

(my emphasis)

So even on systems with newer versions of CMake installed, having cmake_minimum_required(VERSION 3.0) binds them to how CMake behaved as of that release. The last CMake 3.x release was 5+ years ago (v3.0.2).

This change resolves this warning currently seen in many of LightGBM's supported platforms:

  CMake Deprecation Warning at CMakeLists.txt:35 (cmake_minimum_required):
    Compatibility with CMake < 3.5 will be removed from a future version of
    CMake.

    Update the VERSION argument <min> value or use a ...<max> suffix to tell
    CMake that the project does not need compatibility with older versions.

(example macOS sdist build this was observed on)

Why 3.18?

From https://cliutils.gitlab.io/modern-cmake/chapters/intro/installing.html

Your CMake version should be newer than your compiler. It should be newer than the libraries you are using (especially Boost

And from https://cliutils.gitlab.io/modern-cmake/chapters/intro/dodonot.html

What minimum to choose

  • 3.12: C++20
  • 3.17/3.18: CUDA
  • 3.19: First to support Apple Silicon

I'm mainly recommending v3.18 to support the CUDA builds here.

Other evidence it could be ok:

@jameslamb jameslamb changed the title WIP: [cmake] [c++] require CMake 3.18+ [cmake] [c++] require CMake 3.18+ Jan 8, 2024
@jameslamb jameslamb marked this pull request as ready for review January 8, 2024 04:51
@jameslamb
Copy link
Collaborator Author

Thanks for the review @guolinke ! I think this will really help with the next batch of packaging fixes I'd like to make (especially around M1/M2/M3 macOS).

@jameslamb jameslamb merged commit ec97d36 into master Jan 9, 2024
41 checks passed
@jameslamb jameslamb deleted the cmake-version branch January 9, 2024 04:49
@jameslamb jameslamb mentioned this pull request Jan 17, 2024
22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LightGBM is incompatible with older versions of CMake
2 participants