tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[PATCH] cmake/build.mk: Hide non-buildlink3 libraries from cmake
Currently, when configuring a build, cmake will rummage around in the
file system for libraries and header files under LOCALBASE -- not via
wrapper arguments, but by opening and reading files directly itself
through the cmake commands find_package, find_library, &c.
This defeats various quality control measures buildlink3 is supposed
to ensure and bypasses dependencies' buildlink3.mk configurations, for
all packages built with cmake.
The attached patch changes devel/cmake/build.mk to set
CMAKE_FIND_USE_CMAKE_SYSTEM_PATH to OFF, and add BUILDLINK_DIR to
CMAKE_PREFIX_PATH, so that:
1. cmake will not look in LOCALBASE by default.
2. cmake will look in BUILDLINK_DIR by default.
This is intended to improve isolation from transitive dependencies,
detect cases of missing direct buildlink3 dependencies which might
also be missing necessary buildlink3 configuration, and likely also
fix a related class of problems in cross-builds.
More background in this thread from back in May, including failed
attempts to achieve similar results:
https://mail-index.netbsd.org/tech-pkg/2024/05/15/msg029269.html
I have tested this on a handful of packages -- enough to verify it
detects missing buildlink3.mk includes as intended -- but I haven't
run a bulk build. I have been holding off on doing anything with the
patch until the branch is cut. Since it materially changes how
cmake-based packages are built, it probably requires a mass-revbump of
anything using cmake/build.mk and their transitive dependents.
Should probably run a bulk build with this before committing to see
what kind of fallout to expect, but realistically I won't get to that
myself until mid-January. Should probably also apply the same change
to the USE_CMAKE=yes logic. I'm posting this here so the patch
doesn't get forgotten, at least, while I'm busy with other affairs.
From 264cc4cbbfe3372fd4bc7509e9cbfea34b6647d4 Mon Sep 17 00:00:00 2001
From: Taylor R Campbell <riastradh%NetBSD.org@localhost>
Date: Wed, 27 Nov 2024 03:57:19 +0000
Subject: [PATCH] devel/cmake/build.mk: Limit cmake's perspective to
buildlink3.
Hide the system path, i.e., LOCALBASE, from cmake functions like
find_package, find_path, &c.
XXX Need to do a mass revbump of all packages that use cmake -- and
probably deal with a lot of fallout.
---
devel/cmake/build.mk | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/devel/cmake/build.mk b/devel/cmake/build.mk
index 6401528ab819..a49f89eac453 100644
--- a/devel/cmake/build.mk
+++ b/devel/cmake/build.mk
@@ -58,6 +58,10 @@ OPSYSVARS+= CMAKE_CONFIGURE_ARGS
# mid-build.
CMAKE_CONFIGURE_ARGS+= -DFETCHCONTENT_FULLY_DISCONNECTED=ON
+# Ensure cmake only looks in the sanitized buildlink directory for
+# find_package/program/library/file/path.
+CMAKE_CONFIGURE_ARGS+= -DCMAKE_FIND_USE_CMAKE_SYSTEM_PATH=OFF
+CMAKE_PREFIX_PATH+= ${BUILDLINK_DIR}
CONFIGURE_ENV+= BUILDLINK_DIR=${BUILDLINK_DIR}
Home |
Main Index |
Thread Index |
Old Index