cmake: fetch libtiff and FFTW instead of relying on system libs

Both are leaf deps (JFJochPreview / JFJochIndexing) that only our own code
looks for, so building them ourselves removes the system-package lottery and
gives a reproducible, statically-linked build on every platform.

- libtiff: FetchContent, library only (jbig/zstd/lzma/jpeg/old-jpeg/tools/
  tests off). The C++ binding (TIFF::CXX / libtiffxx) is packaged
  inconsistently across distros -- missing on Rocky 9 -- and absent on
  Windows, so find_package(TIFF COMPONENTS CXX) was unreliable; that call is
  removed and JFJochPreview links the tiff/tiffxx targets directly. GitHub
  mirror because upstream (gitlab) is unreachable from some restricted hosts.
- FFTW: FetchContent single precision (ENABLE_FLOAT) from the release tarball
  -- the git repo ships no pre-generated codelets (needs OCaml genfft). It's
  now always available, so the CPU FFT indexer is always built and
  JFJOCH_USE_FFTW always defined; the "FFTW disabled" path is gone. Static
  (libfftw3f.a) via the global BUILD_SHARED_LIBS OFF.

Verified on Linux: jfjoch_viewer builds and links libfftw3f.a + libtiff*.a,
all static.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-19 22:16:05 +02:00
co-authored by Claude Opus 4.8
parent fcbe19103d
commit 0220c6376d
4 changed files with 34 additions and 23 deletions
+29 -8
View File
@@ -63,14 +63,6 @@ IF (CMAKE_CUDA_COMPILER)
ENDIF()
ENDIF()
FIND_LIBRARY(FFTWF_LIBRARY NAMES libfftw3f.a libfftw3f.so fftw3f DOC "FFTW single-precision library"
PATHS /usr/lib /usr/lib64 /usr/lib/x86_64-linux-gnu/)
CHECK_INCLUDE_FILE(fftw3.h HAS_FFTW3_H)
IF(HAS_FFTW3_H AND FFTWF_LIBRARY)
ADD_COMPILE_DEFINITIONS(JFJOCH_USE_FFTW)
ENDIF()
INCLUDE_DIRECTORIES(include)
include(FetchContent)
@@ -173,6 +165,35 @@ ELSE()
FetchContent_MakeAvailable(zstd sls_detector_package catch2 hdf5 spdlog httplib)
ENDIF()
# libtiff (used by JFJochPreview in every build mode): build it ourselves. Its C++ binding
# (tiffxx) is packaged inconsistently across distros (missing on Rocky 9) and absent on
# Windows. Library only; the SET()s below are libtiff's own codec/tool switches. The GitHub
# mirror is used because upstream (gitlab) is unreachable from some restricted build hosts.
SET(jbig OFF)
SET(zstd OFF)
SET(lzma OFF)
SET(jpeg OFF)
SET(old-jpeg OFF)
SET(tiff-tools OFF)
SET(tiff-tests OFF)
FetchContent_Declare(tiff
GIT_REPOSITORY https://github.com/fleon-psi/libtiff
GIT_TAG v4.6.0
EXCLUDE_FROM_ALL)
FetchContent_MakeAvailable(tiff)
# FFTW single precision (target fftw3f): the CPU fallback indexer, enables JFJOCH_USE_FFTW.
# Built from the release tarball -- the git repo ships no pre-generated codelets (needs the
# OCaml genfft). It's a fallback, so no aggressive SIMD tuning (plain scalar build is fine).
SET(ENABLE_FLOAT ON CACHE BOOL "" FORCE)
SET(BUILD_TESTS OFF CACHE BOOL "" FORCE)
FetchContent_Declare(fftw
URL https://www.fftw.org/fftw-3.3.10.tar.gz
URL_HASH SHA256=56c932549852cddcfafdab3820b0200c7742675be92179e59e6215b340e26467
EXCLUDE_FROM_ALL)
FetchContent_MakeAvailable(fftw)
ADD_COMPILE_DEFINITIONS(JFJOCH_USE_FFTW)
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.)
+3 -7
View File
@@ -39,10 +39,6 @@ ELSE()
TARGET_LINK_LIBRARIES(JFJochIndexing Eigen3::Eigen)
ENDIF()
IF(HAS_FFTW3_H AND FFTWF_LIBRARY)
TARGET_SOURCES(JFJochIndexing PRIVATE FFTIndexerCPU.cpp FFTIndexerCPU.h)
TARGET_LINK_LIBRARIES(JFJochIndexing ${FFTWF_LIBRARY})
MESSAGE(STATUS "FFT single-precision library found: ${FFTWF_LIBRARY}")
ELSE()
MESSAGE(WARNING "FFTW disabled")
ENDIF()
# FFTW (fftw3f) is always available via FetchContent -> the CPU FFT indexer is always built.
TARGET_SOURCES(JFJochIndexing PRIVATE FFTIndexerCPU.cpp FFTIndexerCPU.h)
TARGET_LINK_LIBRARIES(JFJochIndexing fftw3f)
+1 -2
View File
@@ -2,7 +2,6 @@ include(ExternalProject)
find_package(ZLIB REQUIRED)
find_package(JPEG REQUIRED)
find_package(TIFF REQUIRED COMPONENTS CXX)
ADD_LIBRARY(JFJochPreview STATIC
JFJochTIFF.cpp JFJochTIFF.h
@@ -16,5 +15,5 @@ ADD_LIBRARY(JFJochPreview STATIC
)
TARGET_LINK_LIBRARIES(JFJochPreview PUBLIC JFJochZMQ JFJochCommon CBORStream2FrameSerialize)
TARGET_LINK_LIBRARIES(JFJochPreview PUBLIC JPEG::JPEG TIFF::TIFF TIFF::CXX ZLIB::ZLIB)
TARGET_LINK_LIBRARIES(JFJochPreview PUBLIC JPEG::JPEG tiff tiffxx ZLIB::ZLIB)
+1 -6
View File
@@ -133,9 +133,4 @@ ELSE()
qt_import_plugins(jfjoch_viewer INCLUDE Qt::QXcbIntegrationPlugin)
ENDIF()
IF(HAS_FFTW3_H AND FFTWF_LIBRARY)
TARGET_LINK_LIBRARIES(jfjoch_viewer ${FFTWF_LIBRARY})
MESSAGE(STATUS "FFT single-precision library found: ${FFTWF_LIBRARY}")
ELSE()
MESSAGE(WARNING "FFTW disabled")
ENDIF()
TARGET_LINK_LIBRARIES(jfjoch_viewer fftw3f)