pkgsrc-Changes archive

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

CVS commit: pkgsrc/devel/cmake



Module Name:    pkgsrc
Committed By:   riastradh
Date:           Fri Jan 24 21:23:07 UTC 2025

Modified Files:
        pkgsrc/devel/cmake: build.mk configure-settings.mk

Log Message:
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.

Pass pkgsrc-defined CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH through
to cmake as environment variables rather than as cmake variables, and
do the same with CMAKE_PREFIX_PATH.  This way, the project can define
its own paths -- as cmake intends -- without overriding pkgsrc's
BUILDLINK_DIR paths.

As a next step, we should set CMAKE_IGNORE_PREFIX_PATH to ignore
${LOCALBASE} in order to conceal it harder.  It won't stop cmake from
finding things it shouldn't through paths exposed by pkg-config but
it might stop cmake from finding things it shouldn't by other paths
like projects putting ${PREFIX} or /usr/pkg in CMAKE_PREFIX_PATH
explicitly.  However, that step will have more fallout, so I'll do it
separately.

Almost all the fallout has been resolved for this revision of the
change, either by tweaking the mechanism (like setting CMAKE_*
environemnt variables instead of cmake variables) or by tweaking
buildlink3 files.  Let me know if anything else pops up -- usually in
the form of `CMake Error' at configure time failing to find
dependencies.

XXX Need mass revbump of all packages that use devel/cmake/build.mk
just in case this changed anything about the build.

Proposed on tech-pkg:
https://mail-index.netbsd.org/tech-pkg/2024/12/25/msg030256.html


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 pkgsrc/devel/cmake/build.mk
cvs rdiff -u -r1.2 -r1.3 pkgsrc/devel/cmake/configure-settings.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/devel/cmake/build.mk
diff -u pkgsrc/devel/cmake/build.mk:1.20 pkgsrc/devel/cmake/build.mk:1.21
--- pkgsrc/devel/cmake/build.mk:1.20    Thu Jan 16 07:48:08 2025
+++ pkgsrc/devel/cmake/build.mk Fri Jan 24 21:23:07 2025
@@ -1,4 +1,4 @@
-# $NetBSD: build.mk,v 1.20 2025/01/16 07:48:08 pho Exp $
+# $NetBSD: build.mk,v 1.21 2025/01/24 21:23:07 riastradh Exp $
 #
 # This Makefile fragment supports building using the CMake build tool.
 #
@@ -60,6 +60,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}
 

Index: pkgsrc/devel/cmake/configure-settings.mk
diff -u pkgsrc/devel/cmake/configure-settings.mk:1.2 pkgsrc/devel/cmake/configure-settings.mk:1.3
--- pkgsrc/devel/cmake/configure-settings.mk:1.2        Fri Jan 20 13:08:07 2023
+++ pkgsrc/devel/cmake/configure-settings.mk    Fri Jan 24 21:23:07 2025
@@ -1,4 +1,4 @@
-# $NetBSD: configure-settings.mk,v 1.2 2023/01/20 13:08:07 adam Exp $
+# $NetBSD: configure-settings.mk,v 1.3 2025/01/24 21:23:07 riastradh Exp $
 #
 # This file handles packages that use CMake as their primary build
 # system. For more information about CMake, see http://www.cmake.org/.
@@ -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.
@@ -81,6 +87,19 @@ CMAKE_CONFIGURE_ARGS+=       -DCMAKE_INSTALL_L
 CMAKE_CONFIGURE_ARGS+= -DCMAKE_APPLE_SILICON_PROCESSOR=arm64
 .endif
 
+# We define the environment variables CMAKE_PREFIX_PATH &c., rather
+# than cmake variables of the same name, because the environment
+# variables are meant to be set by the caller (e.g., packaging system),
+# while the cmake variables are meant to be set by the project (i.e.,
+# CMakeFiles.txt and similar), and some projects do set them.
 .if defined(CMAKE_PREFIX_PATH)
-CMAKE_CONFIGURE_ARGS+= -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH:ts;:Q}
+CONFIGURE_ENV+=                CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH:ts::Q}
+.endif
+
+.if defined(CMAKE_INCLUDE_PATH)
+CONFIGURE_ENV+=                CMAKE_INCLUDE_PATH=${CMAKE_INCLUDE_PATH:ts::Q}
+.endif
+
+.if defined(CMAKE_LIBRARY_PATH)
+CONFIGURE_ENV+=                CMAKE_LIBRARY_PATH=${CMAKE_LIBRARY_PATH:ts::Q}
 .endif



Home | Main Index | Thread Index | Old Index