* On 2024-05-15 at 16:41 BST, Adam wrote:
CMake's find_library() function is apparently not fit for purpose in a pkgsrc environment. It is not buildlink-aware, and will simply go looking around the file system for arbitrary libraries.How about changing Modules/Platform/UnixPaths.cmake to optionally take only buildlink directory into account, something like: set(PKGSRC_BUILDLINK_DIR "$ENV{BUILDLINK_DIR}" CACHE STRING "PkgSrc buildlink directory") if(PKGSRC_BUILDLINK_DIR) list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${PKGSRC_BUILDLINK_DIR}") else() list(APPEND CMAKE_SYSTEM_PREFIX_PATH # Standard @LOCALBASE@ /usr/local /usr / ) endif()
Unfortunately this doesn't work. There are just too many places scattered all over the cmake code where random directories are added and even in the core code it'll try to make new ones e.g. with arch-specific subdirectories added. I wrote up a patch similar to this and it still ended up looking in LOCALBASE, despite purging it from every location.
I have however found CMAKE_SYSTEM_IGNORE_PATH may be a solution. It's not ideal as we will have to laboriously add every possible subdirectory to it (you can't just say "ignore everything under /usr/local", for example), but we can at least start with some of the more obvious ones and go from there.
I'll do some more testing, put it through a bulk build, and then propose something for commit.
-- Jonathan Perkin - mnx.io - pkgsrc.smartos.org Open Source Complete Cloud www.tritondatacenter.com