From ac50e862493341a37b2e254ebbee04da2b9f0739 Mon Sep 17 00:00:00 2001 From: Guofang Date: Fri, 6 Nov 2026 12:25:23 +0800 Subject: [PATCH] Generate a CMake file that locates the rocky9 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 under lib64) for CMake and can restrict lookups to the prefix with GW_SOURCE_STACK_ONLY. Co-Authored-By: Claude Sonnet 5.5 --- rocky9/Dockerfile | 2 ++ rocky9/source-stack.cmake | 50 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 rocky9/source-stack.cmake diff --git a/rocky9/Dockerfile b/rocky9/Dockerfile index b23417f..3ce15c1 100644 --- a/rocky9/Dockerfile +++ b/rocky9/Dockerfile @@ -813,4 +813,6 @@ 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 ${PREFIX}/share/source-stack/source-stack.cmake + CMD ["/bin/bash"] diff --git a/rocky9/source-stack.cmake b/rocky9/source-stack.cmake new file mode 100644 index 0000000..6b29734 --- /dev/null +++ b/rocky9/source-stack.cmake @@ -0,0 +1,50 @@ +# Installed 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) + +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}/lib64" "${_ss_p}/lib") + +# pkg_check_modules() reads PKG_CONFIG_PATH at call time. +set(_ss_pc "${_ss_p}/lib64/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}") +unset(_ss_p) +unset(_ss_pc)