tech-pkg archive

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

Re: [PATCH] cmake/build.mk: Hide non-buildlink3 libraries from cmake



On Sat, Apr 05, 2025 at 10:35:45AM +0000, Taylor R Campbell wrote:
> > Date: Sat, 5 Apr 2025 19:14:21 +1100
> > From: Paul Ripke <stix%stix.id.au@localhost>
> > 
> > Finally updating to pkgsrc-2025Q1, and tripping over what appears to
> > be breakage due to this? Looks like ${WRKDIR} is leaking into installed
> > cmake files. I tripped over this with cad/occt, used from
> > e.g. wip/prusaslicer, and I've also tried and failed to remove the leak
> > from wip/soqt. I *think* that the boost ones are harmless, but still
> > look messy.
> 
> Well, that's frustrating.
> 
> > I guess maybe CHECK_WRKREF could catch this?
> 
> Yes, we should adapt CHECK_WRKREF to catch this.  It'll require some
> work because not all of the wrkrefs are necessarily problems, as you
> noted, but probably everything in INTERFACE_LINK_LIBRARIES lines is a
> problem.
> 
> > ksh$ grep -r pkgwrk /usr/pkg/lib/cmake
> > /usr/pkg/lib/cmake/minizip-ng/minizip-ng.cmake:  INTERFACE_LINK_LIBRARIES "/tmp/pkgwrk/archivers/minizip-ng/work/.buildlink/lib/libz-ng.so;/usr/lib/libbz2.so;lzma;zstd;ssl;crypto"
> > /usr/pkg/lib/cmake/mongoc-1.0/mongoc-targets.cmake:  INTERFACE_LINK_LIBRARIES "/tmp/pkgwrk/databases/mongo-c-driver/work/.buildlink/lib/libsnappy.so;/usr/lib/libz.so;/usr/pkg/lib/libzstd.so;mongo::bson_static;mongo::detail::c_dependencies"
> > /usr/pkg/lib/cmake/opencascade/OpenCASCADEDrawTargets.cmake:  INTERFACE_LINK_LIBRARIES "TKernel;TKG2d;TKGeomBase;TKG3d;TKMath;TKBRep;TKGeomAlgo;TKShHealing;TKMesh;TKService;TKHLR;TKTopAlgo;/tmp/pkgwrk/cad/occt/work/.buildlink/lib/libtcl86.so;/tmp/pkgwrk/cad/occt/work/.buildlink/lib/libtk86.so;X11;pthread;rt;stdc++"
> 
> The workaround we have used for this has been something like
> 
> SUBST_CLASSES+=		unbl3
> SUBST_MESSAGE.unbl3=	Undoing buildlink3 paths in cmake exports.
> SUBST_STAGE.unbl3=	post-build
> SUBST_FILES.unbl3+=	${CMAKE_BUILD_DIR}/src/CMakeFiles/Export/*/*Targets.cmake
> SUBST_SED.unbl3+=	-e 's,${BUILDLINK_DIR}/lib,${PREFIX}/lib,g'

Yah, I tried pretty much that with wip/soqt, and ran into the fact that
libGL isn't in ${PREFIX}. In that case, I just dropped the whole path,
which seems to work.

For occt, the following works for me:

SUBST_CLASSES+=        unbl3
SUBST_MESSAGE.unbl3=   Undoing buildlink3 paths in cmake exports.
SUBST_STAGE.unbl3=     post-build
SUBST_FILES.unbl3+=    ${CMAKE_BUILD_DIR}/CMakeFiles/Export/*/OpenCASCADE*Targets.cmake
SUBST_SED.unbl3+=      -e 's,${BUILDLINK_DIR}/lib,${PREFIX}/lib,g'

I also found that there's a lone object file referenced from cmake
modules for x11/qt6-qtbase, preventing wip/py-pyside6 from building:

BUILDLINK_FILES.qt6-qtbase+=   qt6/lib/objects-Release/ExampleIconsPrivate_resources_1/.qt/rcc/*.o

> However, this approach is not scaling well (see, e.g., x11/libfm-qt),
> and I suspect the problem is better treated at the source.
> 
> The cmake documentation has some recommendations, in the context of
> relocatable packages (even though pkgsrc does not make relocatable
> packages), but I am not yet sure immediately how to implement them:
> 
> https://cmake.org/cmake/help/latest/prop_tgt/INTERFACE_LINK_LIBRARIES.html#creating-relocatable-packages
> https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-relocatable-packages

Yes, I tried to fix wip/soqt "properly", but gave up and reused the
ugly hack.

I'm finding cmake rather impenetrable at this level. I've written
simple cmake configs from scratch, but some of these are perverse in
their complexity.

> In the case of chat/occt, it looks like the logic to generate target
> link libraries might live in ${WRKSRC}/adm/cmake/occt_toolkit.cmake.

afaict, correct: but I'm still failing to grok how & what exactly it does for
install(... EXPORT...

-- 
Paul Ripke
"Great minds discuss ideas, average minds discuss events, small minds
 discuss people."
-- Disputed: Often attributed to Eleanor Roosevelt. 1948.


Home | Main Index | Thread Index | Old Index