From 729ada57693864a5224a9e56fd6e88532b06ca44 Mon Sep 17 00:00:00 2001 From: Guofang Date: Wed, 28 Oct 2026 09:56:57 +0800 Subject: [PATCH] Generate a CMake file that locates the debian13 dependencies Install ${PREFIX}/share/source-stack/source-stack.cmake as the last step. It mirrors the image's ENV block (prefix, pkg-config and library paths) for CMake and can restrict lookups to the prefix with GW_SOURCE_STACK_ONLY. Co-Authored-By: Claude Sonnet 5.5 --- debian13/Dockerfile | 6 ++++ debian13/source-stack.cmake.in | 52 ++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 debian13/source-stack.cmake.in diff --git a/debian13/Dockerfile b/debian13/Dockerfile index 87066fa..754cc44 100644 --- a/debian13/Dockerfile +++ b/debian13/Dockerfile @@ -820,4 +820,10 @@ RUN --mount=type=bind,from=sources,source=duckdb-v1.5.6.tar.gz,target=/tmp/duckd && cmake --build build --parallel "$(nproc)" --target install \ && rm -rf build src ui-src +COPY source-stack.cmake.in /tmp/ +RUN mkdir -p ${PREFIX}/share/source-stack \ + && sed "s|@MULTIARCH@|$(gcc -dumpmachine)|" /tmp/source-stack.cmake.in \ + > ${PREFIX}/share/source-stack/source-stack.cmake \ + && rm /tmp/source-stack.cmake.in + CMD ["/bin/bash"] diff --git a/debian13/source-stack.cmake.in b/debian13/source-stack.cmake.in new file mode 100644 index 0000000..8f792b6 --- /dev/null +++ b/debian13/source-stack.cmake.in @@ -0,0 +1,52 @@ +# Generated into the image at ${PREFIX}/share/source-stack/source-stack.cmake. +# +# Points CMake at the dependencies installed by this image. It mirrors the +# Dockerfile's ENV block (PATH, PKG_CONFIG_PATH, CMAKE_PREFIX_PATH, +# C_INCLUDE_PATH/CPLUS_INCLUDE_PATH, LIBRARY_PATH) for CMake's own lookups. +# The prefix is derived from this file's location, so it also works when the +# prefix is moved. Include it after project(), before the first find_package(). +# +# GW_SOURCE_STACK_ONLY resolve libraries and packages only below the prefix + +option(GW_SOURCE_STACK_ONLY + "Resolve libraries and packages only below the source-stack prefix" OFF) + +get_filename_component(_ss_p "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE) +set(_ss_multiarch "@MULTIARCH@") + +list(PREPEND CMAKE_PREFIX_PATH "${_ss_p}") +list(PREPEND CMAKE_PROGRAM_PATH "${_ss_p}/bin") +list(PREPEND CMAKE_INCLUDE_PATH "${_ss_p}/include") +list(PREPEND CMAKE_LIBRARY_PATH "${_ss_p}/lib/${_ss_multiarch}" "${_ss_p}/lib") + +# pkg_check_modules() reads PKG_CONFIG_PATH at call time. +set(_ss_pc "${_ss_p}/lib/${_ss_multiarch}/pkgconfig:${_ss_p}/lib/pkgconfig:${_ss_p}/share/pkgconfig") +if(GW_SOURCE_STACK_ONLY) + # PKG_CONFIG_LIBDIR replaces the default search path, so system .pc files are ignored. + set(ENV{PKG_CONFIG_LIBDIR} "${_ss_pc}") + set(ENV{PKG_CONFIG_PATH} "") + # Build tools come from the system; look them up before system paths are switched off. + find_program(PKG_CONFIG_EXECUTABLE NAMES pkg-config pkgconf) + set(CMAKE_FIND_USE_CMAKE_SYSTEM_PATH OFF) + set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF) + set(CMAKE_FIND_ROOT_PATH "${_ss_p}") + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +else() + if(NOT "$ENV{PKG_CONFIG_PATH}" STREQUAL "") + set(ENV{PKG_CONFIG_PATH} "${_ss_pc}:$ENV{PKG_CONFIG_PATH}") + else() + set(ENV{PKG_CONFIG_PATH} "${_ss_pc}") + endif() +endif() + +# protoc installed next to the libraries, unless the caller chose one. +if(NOT Protobuf_PROTOC_EXECUTABLE AND EXISTS "${_ss_p}/bin/protoc") + set(Protobuf_PROTOC_EXECUTABLE "${_ss_p}/bin/protoc" CACHE FILEPATH "protoc") +endif() + +message(STATUS "source-stack: ${_ss_p} (${_ss_multiarch})") +unset(_ss_p) +unset(_ss_multiarch) +unset(_ss_pc)