Files
source-stack/rocky9/source-stack.cmake
T
GuofangandClaude Sonnet 5.5 ac50e86249 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 <noreply@anthropic.com>
2026-11-06 12:25:23 +08:00

51 lines
2.2 KiB
CMake

# 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)