Files
Jungfraujoch/preview/CMakeLists.txt
T
leonarski_fandClaude Opus 4.8 cd394c5249
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
CMake: vendor Eigen (5.0.1) and libjpeg-turbo so the build is self-contained
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>
2026-06-20 07:55:56 +02:00

65 lines
2.6 KiB
CMake

include(ExternalProject)
find_package(ZLIB 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
JFJochJPEG.cpp JFJochJPEG.h
PreviewCounter.cpp PreviewCounter.h
PreviewImage.cpp PreviewImage.h
ZMQPreviewSocket.cpp
ZMQPreviewSocket.h
ZMQMetadataSocket.cpp
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)