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

Bump CMake minimum version to 3.13 #430

Merged
merged 2 commits into from
Sep 10, 2024
Merged

Conversation

nitrix
Copy link
Contributor

@nitrix nitrix commented Sep 9, 2024

What

This bumps the minimum CMake version from 3.8.2 to 3.13.0.

Goal

Hiding this warning message:

Not searching for unused variables given on the command line.
[cmake] CMake Warning (dev) at vendor/cglm/CMakeLists.txt:15 (option):
[cmake]   Policy CMP0077 is not set: option() honors normal variables.  Run "cmake
[cmake]   --help-policy CMP0077" for policy details.  Use the cmake_policy command to
[cmake]   set the policy and suppress this warning.
[cmake] 
[cmake]   For compatibility with older versions of CMake, option is clearing the
[cmake]   normal variable 'CGLM_STATIC'.
[cmake] This warning is for project developers.  Use -Wno-dev to suppress it.
[cmake] 

Why

Different versions of CMake comes with different policies enabled by default.

As of 3.13.0, CMake introduced the policy CMP0077 which, because this project is on an older version, wants users vendoring cglm to specify whether they prefer the OLD or NEW behavior, resulting in either set(CMAKE_POLICY_DEFAULT_CMP0077 X) before add_subdirectory(vendor/cglm) or cmake_policy(CMP0077 X) for the whole project.

Explanation

The NEW behavior (that version 3.13.0 introduced) is sane and desirable for everybody.

Prior, option() was copying identically named variables into the cache and then ignoring any future mutations unless re-configuring the whole project. Now, option() prefers to do nothing, not even caching, essentially honoring at all times what the early variable definition requested (that option() would've normally set).

This allows for users to properly configure CGML's options even though it's a subdirectory and to not worry about possible overrides or left over cache headaches.

e.g.

option(CGLM_STATIC "Static build" ON)
add_subdirectory(vendor/cglm)
target_add_library(example PRIVATE cglm)

Backwards compatibility

  • Users that explicitly want to keep the old behavior would've already needed the policy line and the version upgrade wont distrupt their choice. That's the whole point of configurable CMake policies.

  • Everybody else on newer CMake versions that didn't pick a policy accidently rely on the new behavior and therefore not impacted by the new version because the default maintains that behavior.

Notes

It seems 3.8.2 was in 2017 and 3.13.0 in 2018. Both are old enough that probably everyone and all the major distros are well beyond. Personally, I use MinGW a lot and am on 3.26.4, while officially the latest is 3.30.3.

@recp recp merged commit 93a2926 into recp:master Sep 10, 2024
69 of 74 checks passed
@recp
Copy link
Owner

recp commented Sep 10, 2024

Hi @nitrix, the PR is merged, thanks for your contributions 🚀

@nitrix nitrix deleted the feat/cmake-3.13 branch September 11, 2024 18:38
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