fix(cmake): pybind11.pc prefix and CMP0190 default across reconfigure - #6165
Draft
henryiii wants to merge 2 commits into
Draft
fix(cmake): pybind11.pc prefix and CMP0190 default across reconfigure#6165henryiii wants to merge 2 commits into
henryiii wants to merge 2 commits into
Conversation
…ROOTDIR Fixes item 7 of pybind#6159.
henryiii
marked this pull request as draft
September 2, 2026 17:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI text below 🤖
Two unrelated CMake fixes, one per commit, so they can be cherry-picked separately.
pybind11.pc prefix. The
cmake_path(RELATIVE_PATH ...)branch gave the base directory as the literal stringCMAKE_INSTALL_DATAROOTDIRinstead of its value, so on CMake 3.20 and later the installedpybind11.pchad an emptyprefix=. The relative path from the data root to the install prefix is also not what the.pcfile needs, which is a path relative to${pcfiledir}. Thewhile()branch below already computes the correct value, so thecmake_pathbranch is removed and the loop is used for all CMake versions. With-DCMAKE_INSTALL_PREFIX=/opt/xthe file now hasprefix=${pcfiledir}/../.., and-DCMAKE_INSTALL_DATAROOTDIR=lib/foo/sharegivesprefix=${pcfiledir}/../../../...CMP0190 default across reconfigure. The cross-compiling default used the marker
_PYBIND11_USE_CROSSCOMPILING_DEFAULTED, which is not cached, whileoption()cachesPYBIND11_USE_CROSSCOMPILINGasOFF. On the second configure the marker was empty and the default becameOFF. The default is now computed beforeoption()and given as the option default, so the cache keeps it. An explicit-DPYBIND11_USE_CROSSCOMPILING=OFFis still respected.tools/pybind11Common.cmakekeeps the same default forfind_package()consumers, where the option does not exist.Suggested changelog entry:
prefix=value in the installedpybind11.pc, which was empty with CMake 3.20 and later.PYBIND11_USE_CROSSCOMPILINGwhen CMake is configured a second time.