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
> Date: Wed, 25 Dec 2024 03:35:50 +0000
> From: Taylor R Campbell <riastradh%NetBSD.org@localhost>
>
> 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.
Turns out it is also necessary to explicitly allow directories like
/usr/include and /usr/lib -- that is, anything listed in
COMPILER_INCLUDE_DIRS and COMPILER_LIB_DIRS -- or else packages fail
to find base libraries like libm, libpthread, libz.
The attached patch addresses this, by adding new pkgsrc mk variables
CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH, echoing the cmake variable
names, and populating them with COMPILER_INCLUDE/LIB_DIRS (qualified
by _CROSS_DESTDIR since cmake reads from these paths at build-time).
So far a bulk build has made a lot more progress with this version
than with the previous version.
From d6a4c6fed1481f8b0cb38eb93b2bf5fbd9240ad4 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 LOCALBASE from cmake functions like find_package, find_path, &c.
But don't hide COMPILER_INCLUDE_DIRS and COMPILER_LIB_DIRS -- we only
want to hide undeclared pkgsrc packages, not system libraries.
New make variables CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH are
passed through, as lists like CMAKE_PREFIX_PATH, to cmake.
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 | 6 ++++++
devel/cmake/configure-settings.mk | 14 ++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/devel/cmake/build.mk b/devel/cmake/build.mk
index 6401528ab819..76539f696672 100644
--- a/devel/cmake/build.mk
+++ b/devel/cmake/build.mk
@@ -58,6 +58,12 @@ OPSYSVARS+= CMAKE_CONFIGURE_ARGS
# mid-build.
CMAKE_CONFIGURE_ARGS+= -DFETCHCONTENT_FULLY_DISCONNECTED=ON
+# Ensure cmake only looks in system files or in the sanitized buildlink
+# directory for find_package/program/library/file/path.
+CMAKE_CONFIGURE_ARGS+= -DCMAKE_FIND_USE_CMAKE_SYSTEM_PATH:BOOL=OFF
+CMAKE_PREFIX_PATH+= ${BUILDLINK_DIR}
+CMAKE_INCLUDE_PATH+= ${COMPILER_INCLUDE_DIRS:@.d.@${_CROSS_DESTDIR:U}${.d.}@}
+CMAKE_LIBRARY_PATH+= ${COMPILER_LIB_DIRS:@.d.@${_CROSS_DESTDIR:U}${.d.}@}
CONFIGURE_ENV+= BUILDLINK_DIR=${BUILDLINK_DIR}
diff --git a/devel/cmake/configure-settings.mk b/devel/cmake/configure-settings.mk
index d3b2742dadb0..a018c171af87 100644
--- a/devel/cmake/configure-settings.mk
+++ b/devel/cmake/configure-settings.mk
@@ -27,6 +27,12 @@
# buildlink3.mk so that packages that depend on it can find its
# cmake modules if they use cmake to build.
#
+# CMAKE_INCLUDE_PATH
+# Like CMAKE_PREFIX_PATH but just for include files.
+#
+# CMAKE_LIBRARY_PATH
+# Like CMAKE_PREFIX_PATH but just for libraries.
+#
# CMAKE_USE_GNU_INSTALL_DIRS
# If set to yes, set GNU standard installation directories with pkgsrc
# configured settings. The default is yes.
@@ -84,3 +90,11 @@ CMAKE_CONFIGURE_ARGS+= -DCMAKE_APPLE_SILICON_PROCESSOR=arm64
.if defined(CMAKE_PREFIX_PATH)
CMAKE_CONFIGURE_ARGS+= -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH:ts;:Q}
.endif
+
+.if defined(CMAKE_INCLUDE_PATH)
+CMAKE_CONFIGURE_ARGS+= -DCMAKE_INCLUDE_PATH:PATH=${CMAKE_INCLUDE_PATH:ts;:Q}
+.endif
+
+.if defined(CMAKE_LIBRARY_PATH)
+CMAKE_CONFIGURE_ARGS+= -DCMAKE_LIBRARY_PATH:PATH=${CMAKE_LIBRARY_PATH:ts;:Q}
+.endif
Home |
Main Index |
Thread Index |
Old Index