CMake: vendor Eigen (5.0.1) and libjpeg-turbo so the build is self-contained
Build Packages / Unit tests (push) Failing after 2m41s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Failing after 2m34s
Build Packages / build:rpm (rocky8) (push) Failing after 2m29s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Failing after 2m38s
Build Packages / build:rpm (rocky8_sls9) (push) Failing after 2m34s
Build Packages / build:rpm (rocky8_nocuda) (push) Failing after 2m43s
Build Packages / build:rpm (rocky9_nocuda) (push) Failing after 2m49s
Build Packages / build:rpm (rocky9_sls9) (push) Failing after 2m56s
Build Packages / Generate python client (push) Successful in 21s
Build Packages / Build documentation (push) Successful in 1m9s
Build Packages / Create release (push) Skipped
Build Packages / build:rpm (ubuntu2404) (push) Failing after 2m15s
Build Packages / build:rpm (ubuntu2204) (push) Failing after 2m17s
Build Packages / XDS test (JFJoch plugin) (push) Failing after 2m24s
Build Packages / build:rpm (rocky9) (push) Failing after 2m34s
Build Packages / XDS test (neggia plugin) (push) Failing after 2m23s
Build Packages / DIALS test (push) Failing after 2m29s
Build Packages / XDS test (durin plugin) (push) Failing after 2m41s

Two deps the Linux build picked up from the system were absent on Windows.
Bundle both, unconditionally (matching how libtiff/FFTW are vendored), so the
tree builds without system Eigen/JPEG:

- Eigen 5.0.1 via FetchContent with OVERRIDE_FIND_PACKAGE, so every
  find_package(Eigen3) -- ours, Ceres', and ffbidx' -- resolves to this copy and
  the requested 3.4 version is satisfied by the newer major. ffbidx's bundled
  eigen submodule is disabled (GIT_SUBMODULES "" on fast-indexer) so it no longer
  creates a duplicate Eigen3::Eigen target. Verified on a CUDA build: Ceres 2.3.0,
  the analysis libs, and ffbidx's CUDA code all compile against 5.0.1.

- libjpeg-turbo 3.0.4 via ExternalProject (upstream discourages add_subdirectory);
  built+installed static and imported as JPEG::JPEG, replacing find_package(JPEG)
  in preview/. SIMD is lazy: WITH_SIMD=ON + REQUIRE_SIMD=OFF means NASM-accelerated
  when nasm is present, otherwise a warning and a scalar build (no hard failure).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-20 07:55:56 +02:00
parent 4737eff1a9
commit cd394c5249
3 changed files with 65 additions and 1 deletions
+15
View File
@@ -213,6 +213,21 @@ FetchContent_MakeAvailable(fftw)
TARGET_INCLUDE_DIRECTORIES(fftw3f INTERFACE $<BUILD_INTERFACE:${fftw_SOURCE_DIR}/api>)
ADD_COMPILE_DEFINITIONS(JFJOCH_USE_FFTW)
# Eigen (header-only): consumed by Ceres and by the analysis libs directly, and by ffbidx under
# CUDA. Not auto-provided by FetchContent and absent on Windows, so vendor it here. OVERRIDE_FIND_PACKAGE
# routes every find_package(Eigen3) -- ours, Ceres', ffbidx' -- to this copy and bypasses the version
# request (they ask for 3.4; this is a newer major). ffbidx's own bundled eigen is disabled below
# (GIT_SUBMODULES "" on fast-indexer) so it does not create a duplicate Eigen3::Eigen target.
SET(EIGEN_BUILD_DOC OFF CACHE BOOL "" FORCE)
SET(EIGEN_BUILD_TESTING OFF CACHE BOOL "" FORCE)
SET(EIGEN_BUILD_PKGCONFIG OFF CACHE BOOL "" FORCE)
FetchContent_Declare(Eigen3
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
GIT_TAG 5.0.1
GIT_SHALLOW TRUE
EXCLUDE_FROM_ALL
OVERRIDE_FIND_PACKAGE)
IF (JFJOCH_VIEWER_ONLY)
# Minimal subtree: jfjoch_viewer and only the libraries it transitively links.
# (broker here provides JFJochAPI only; its service targets are gated out.)
+4
View File
@@ -19,10 +19,14 @@ ADD_LIBRARY(JFJochIndexing STATIC
TARGET_LINK_LIBRARIES(JFJochIndexing JFJochCommon JFJochLatticeSearch)
IF (JFJOCH_CUDA_AVAILABLE)
# GIT_SUBMODULES "" -> do not fetch ffbidx's bundled eigen submodule; it would add_subdirectory
# a second Eigen3::Eigen target. ffbidx instead resolves Eigen via the project-level Eigen3
# (OVERRIDE_FIND_PACKAGE in the top-level CMakeLists).
FetchContent_Declare(
fast-indexer
GIT_REPOSITORY https://github.com/paulscherrerinstitute/fast-feedback-indexer/
GIT_TAG ca9e17486a1eb96319a738acef33cc24c9cd8845
GIT_SUBMODULES ""
)
FetchContent_MakeAvailable(fast-indexer)
+46 -1
View File
@@ -1,7 +1,48 @@
include(ExternalProject)
find_package(ZLIB REQUIRED)
find_package(JPEG REQUIRED)
# libjpeg-turbo: upstream does NOT support add_subdirectory/FetchContent inclusion, so build and
# install it out-of-line and import the static lib. (Adapted from aseprite's FindJpegTurbo.cmake.)
# The static lib is `jpeg-static.lib` on MSVC and `libjpeg.a` elsewhere.
IF (MSVC)
SET(LIBJPEG_TURBO_STATIC_SUFFIX "-static")
ELSE()
SET(LIBJPEG_TURBO_STATIC_SUFFIX "")
ENDIF()
SET(LIBJPEG_TURBO_DIR "${CMAKE_CURRENT_BINARY_DIR}/libjpeg-turbo")
SET(LIBJPEG_TURBO_LIBRARY "${LIBJPEG_TURBO_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}jpeg${LIBJPEG_TURBO_STATIC_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}")
SET(LIBJPEG_TURBO_INCLUDE_DIRS "${LIBJPEG_TURBO_DIR}/include")
ExternalProject_Add(libjpeg-turbo-project
GIT_REPOSITORY https://github.com/libjpeg-turbo/libjpeg-turbo
GIT_TAG 3.0.4
PREFIX "${LIBJPEG_TURBO_DIR}"
INSTALL_DIR "${LIBJPEG_TURBO_DIR}"
BUILD_BYPRODUCTS "${LIBJPEG_TURBO_LIBRARY}"
CMAKE_CACHE_ARGS
-DENABLE_SHARED:BOOL=OFF
-DENABLE_STATIC:BOOL=ON
-DWITH_ARITH_DEC:BOOL=ON
-DWITH_ARITH_ENC:BOOL=ON
-DWITH_JPEG8:BOOL=OFF
-DWITH_JPEG7:BOOL=OFF
-DWITH_TURBOJPEG:BOOL=OFF
# Lazy SIMD: use NASM-accelerated SIMD when nasm is present, otherwise warn and build a
# scalar libjpeg (REQUIRE_SIMD=OFF is libjpeg-turbo's default; pinned here to be explicit).
-DWITH_SIMD:BOOL=ON
-DREQUIRE_SIMD:BOOL=OFF
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DCMAKE_INSTALL_LIBDIR:PATH=<INSTALL_DIR>/lib)
# Create the include dir up front so setting INTERFACE_INCLUDE_DIRECTORIES below does not fail.
FILE(MAKE_DIRECTORY ${LIBJPEG_TURBO_INCLUDE_DIRS})
ADD_LIBRARY(JPEG::JPEG STATIC IMPORTED GLOBAL)
SET_TARGET_PROPERTIES(JPEG::JPEG PROPERTIES
IMPORTED_LOCATION "${LIBJPEG_TURBO_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${LIBJPEG_TURBO_INCLUDE_DIRS}")
ADD_LIBRARY(JFJochPreview STATIC
JFJochTIFF.cpp JFJochTIFF.h
@@ -14,6 +55,10 @@ ADD_LIBRARY(JFJochPreview STATIC
ZMQMetadataSocket.h
)
# JPEG::JPEG is an IMPORTED target, so the build-order dependency on the ExternalProject must be
# attached to the consuming target instead.
ADD_DEPENDENCIES(JFJochPreview libjpeg-turbo-project)
TARGET_LINK_LIBRARIES(JFJochPreview PUBLIC JFJochZMQ JFJochCommon CBORStream2FrameSerialize)
TARGET_LINK_LIBRARIES(JFJochPreview PUBLIC JPEG::JPEG tiff tiffxx ZLIB::ZLIB)