# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

find_package(CUDAToolkit REQUIRED)

add_library(hololink_core STATIC
  arp_wrapper.cpp
  data_channel.cpp
  enumerator.cpp
  hololink.cpp
  jesd.cpp
  logging.cpp
  metadata.cpp
  networking.cpp
  packetizer_program.cpp
  reactor.cpp
  timeout.cpp
  )
add_library(hololink::core ALIAS hololink_core)

set_property(TARGET hololink_core PROPERTY POSITION_INDEPENDENT_CODE ON)

target_link_libraries(hololink_core
  PUBLIC
    CUDA::cuda_driver
    fmt::fmt-header-only
)

target_include_directories(hololink_core
  PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>
    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

# Installation of the hololink_core library
set_target_properties(hololink_core PROPERTIES EXPORT_NAME core)
install(TARGETS hololink_core
        EXPORT HololinkTargets
        DESTINATION ${CMAKE_INSTALL_LIBDIR}
        COMPONENT hololink-core)

install(FILES
        arp_wrapper.hpp
        csi_controller.hpp
        named_lock.hpp
        csi_formats.hpp
        data_channel.hpp
        deserializer.hpp
        enumerator.hpp
        hololink.hpp
        jesd.hpp
        logging.hpp
        # Note that logging_internal.hpp is not included in the public release.
        # logging_internal.hpp
        metadata.hpp
        networking.hpp
        nullable_pointer.hpp
        nvtx_trace.hpp
        packetizer_program.hpp
        reactor.hpp
        serializer.hpp
        smart_object_pool.hpp
        timeout.hpp
        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hololink/core
        COMPONENT hololink-core)
