Skip to content

feat(cmake): Use modern FetchContent approaches when available - #6081

Open
LecrisUT wants to merge 6 commits into
pybind:masterfrom
LecrisUT:feat/fetchcontent
Open

feat(cmake): Use modern FetchContent approaches when available#6081
LecrisUT wants to merge 6 commits into
pybind:masterfrom
LecrisUT:feat/fetchcontent

Conversation

@LecrisUT

@LecrisUT LecrisUT commented Jun 3, 2026

Copy link
Copy Markdown

Description

CMake >= 3.24 supports automatic fallback mechanism of find_package -> FetchContent. This is better both for the upstream maintenance and CI, as well as for downstream packagers.

Suggested changelog entry:

  • Introduced PYBIND11_CATCH_TESTS and PYBIND11_EIGEN_TESTS CMake options
  • Switched to using find_package -> FetchContent fallback for third-party dependencies when available (CMake >= 3.24). The DOWNLOAD_* options are deprecated in favor of using PYBIND11_*_TESTS and standard FETCH_CONTENT_* options to control this

@LecrisUT
LecrisUT requested a review from henryiii as a code owner June 3, 2026 13:01
@LecrisUT

LecrisUT commented Jun 3, 2026

Copy link
Copy Markdown
Author

A few follow-ups that I am interested:

  • Dropping the complicated handling of eigen3 find_package stuff
  • Dropping the support of the old eigen3 and catch2 versions
  • Dropping the various Find* modules

@LecrisUT
LecrisUT force-pushed the feat/fetchcontent branch 6 times, most recently from 2cfcab4 to 0c774fc Compare June 3, 2026 16:53
LecrisUT and others added 6 commits July 27, 2026 12:14
FetchContent lowercases the declared name, so the populated source
directory is eigen3_SOURCE_DIR. EIGEN3_INCLUDE_DIR was set from the
empty eigen_SOURCE_DIR, and the Eigen tests could not find Eigen/Core.

Catch2 2.13.10 asks for compatibility with CMake < 3.10. CMake 4 makes
this a deprecation warning, which -Werror=dev turns into an error and
stops the configure step. CMAKE_WARN_DEPRECATED cannot suppress it
because CMP0218 ignores that variable, so raise the policy floor for
the subproject instead.

Also set CATCH_VERSION, which all the Catch status messages report.

Assisted-by: ClaudeCode:claude-opus-5
@henryiii
henryiii force-pushed the feat/fetchcontent branch from 0c774fc to dbda0b1 Compare July 27, 2026 16:20
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