CMAKE_SYSROOT-based rewrite of package search paths breaks superbuilds
Superbuilds often automatically download dependencies, and then build and install them into a path within the build tree. They then go on to find the just built dependency using find_package
, by specifying the prefix where the dependency was just installed in the PATHS
option. However, if CMAKE_SYSROOT is set, that path gets rewritten into the sysroot, to the effect that the dependency is not found.
The documentation indicates that PATHS
should be used for guesses and HINTS
should be used for actual found directories. Does that imply that HINTS
do not get rewritten? If that is the case, the documentation would have to be a lot more explicit on this: e.g. Use HINTS
for paths that refer to locations on the current host system, and PATHS
for paths that refer to typical locations on the host/target system. The are adjusted by SYSROOT, the former not.
Alternatively, a special casing could be made for paths referring to the build tree. However, with every such added bit of magic, the documentation will be more complex, the system less transparent and more difficult to use - and I find that CMake already has far too many surprising and ill-documented magic corner cases.