ADD_LIBRARY(JFJochHDF5Wrappers STATIC
        HDF5Objects.cpp HDF5Objects.h
        H5FDpoison_sec2.c H5FDpoison_sec2.h
        ../compression/bitshuffle/bshuf_h5filter.c
        ../compression/bitshuffle/bshuf_h5filter.h)
set_target_properties(JFJochHDF5Wrappers PROPERTIES POSITION_INDEPENDENT_CODE ON)

TARGET_LINK_LIBRARIES(JFJochHDF5Wrappers Compression hdf5-static)

ADD_LIBRARY(JFJochWriter STATIC
        HDF5DataFile.h  HDF5DataFile.cpp
        HDF5NXmx.cpp      HDF5NXmx.h
        FileWriter.cpp FileWriter.h
        HDF5DataFilePlugin.cpp
        HDF5DataFilePlugin.h
        HDF5DataFilePluginROI.cpp
        HDF5DataFilePluginROI.h
        HDF5DataFilePluginXFEL.cpp
        HDF5DataFilePluginXFEL.h
        HDF5DataFilePluginMX.cpp
        HDF5DataFilePluginMX.h
        HDF5DataFilePluginAzInt.cpp
        HDF5DataFilePluginAzInt.h
        HDF5DataFilePluginDetector.cpp
        HDF5DataFilePluginDetector.h
        HDF5DataFilePluginImageStats.cpp
        HDF5DataFilePluginImageStats.h
        HDF5DataFilePluginReflection.cpp
        HDF5DataFilePluginReflection.h
        HDF5DataFilePluginPerformance.cpp
        HDF5DataFilePluginPerformance.h
)

TARGET_LINK_LIBRARIES(JFJochWriter JFJochPreview JFJochLogger JFJochHDF5Wrappers CBORStream2FrameSerialize)

# The streaming writer and the jfjoch_writer service belong to the Linux server stack, not the
# portable viewer subset: JFJochStreamWriter pulls in JFJochImagePuller (not built in a viewer-only
# tree) and jfjoch_writer uses a fork()/waitpid() multi-process design (<sys/wait.h>, no Windows
# equivalent). The portable JFJochWriter library above is what the CLI tools and viewer need; these
# two targets are not. (Windows/macOS force a portable build, so this also excludes them there.)
IF (NOT JFJOCH_PORTABLE_ONLY)
    ADD_LIBRARY(JFJochStreamWriter StreamWriter.cpp StreamWriter.h)
    TARGET_LINK_LIBRARIES(JFJochStreamWriter JFJochWriter JFJochImagePuller)

    ADD_EXECUTABLE(jfjoch_writer jfjoch_writer.cpp)
    TARGET_LINK_LIBRARIES(jfjoch_writer JFJochStreamWriter)
    INSTALL(TARGETS jfjoch_writer RUNTIME COMPONENT writer)
ENDIF()
