tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: cmake find_library() vs depends



> Date: Wed, 22 May 2024 11:50:43 +0100
> From: Jonathan Perkin <jperkin%mnx.io@localhost>
> 
> 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 tried adding

CMAKE_CONFIGURE_ARGS+=	-DCMAKE_FIND_USE_CMAKE_SYSTEM_PATH=OFF
CMAKE_PREFIX_PATH+=	${BUILDLINK_DIR}

to finance/ledger/Makefile with some of the buildlink3.mk includes
commented out, for gmp and mpfr.  This successfully thwarted cmake
from finding gmp and mpfr, so the build failed.

When I added the gmp and mpfr buildlink3.mk includes back, a clean
build succeeded and the tests passed (at least, all those that passed
before).

So these variables -- CMAKE_FIND_USE_CMAKE_SYSTEM_PATH and
CMAKE_PREFIX_PATH -- might be what we're looking for.  But I haven't
tried a bulk build with this yet in devel/cmake/build.mk (or
equivalent for USE_CMAKE=yes).

If we do apply this we'll probably want to do a tree-wide revbump of
everything using cmake since lots of packages will behave differently
on some systems where they previously accidentally had options enabled
for whatever random dependencies cmake grabbed by rummaging through
LOCALBASE.

https://cmake.org/cmake/help/v3.31/variable/CMAKE_FIND_USE_CMAKE_SYSTEM_PATH.html

There are some other related variables too like
CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH, CMAKE_FIND_USE_INSTALL_PREFIX,
and CMAKE_FIND_USE_PACKAGE_REGISTRY which might be worth setting
similarly to limit where cmake find_* goes rummaging around.


> 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.

There is also CMAKE_SYSTEM_IGNORE_PREFIX_PATH (or
CMAKE_IGNORE_PREFIX_PATH) which is advertised to do what you want:

https://cmake.org/cmake/help/v3.31/variable/CMAKE_IGNORE_PREFIX_PATH.html
https://cmake.org/cmake/help/v3.31/variable/CMAKE_SYSTEM_IGNORE_PREFIX_PATH.html

Except that it doesn't apply to the built-in system path, which is
presumably LOCALBASE, so it may be only useful for (e.g.) hiding
/usr/local when LOCALBASE is /usr/pkg or similar.


Home | Main Index | Thread Index | Old Index