set(PACKAGE data_converters-ngpipes-protobuf)

message(STATUS ${PACKAGE})

find_package(Protobuf REQUIRED)
find_package(gRPC REQUIRED)
find_package(Boost 1.53
        COMPONENTS
        date_time
        program_options
        system
        filesystem
        REQUIRED)
find_package(vaisala-wr-common-dto REQUIRED)
find_package(vaisala-wr-input-dto REQUIRED)
find_package(vaisala-fire-data-manager REQUIRED)
find_package(spdlog REQUIRED)

set(PIPE_NAMES pb2raw raw2pb)
set(PIPE_NAME_INPUT_DTO raw2pb_input_dto)
set(CONF_FILES pb2raw.conf raw2pb.conf)

include_directories(
                ${HDF5_INCLUDE_DIR}
                ${CMAKE_SOURCE_DIR}/ngpipes
                ${CMAKE_SOURCE_DIR}/ngpipes/data_manager_lib
                ${CMAKE_SOURCE_DIR}/sigmet
                ${IRIS_INCLUDE}/data-manager
                ${IRIS_INCLUDE}/common-dto)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

link_libraries(wrdata sws-iris siglog boost_program_options boost_system tirpc
        boost_filesystem boost_regex boost_date_time m dsp-iris antenna-iris config-iris exthdr-iris misc-iris himath-iris spdlog::spdlog)
        
add_executable(raw2pb raw2pb.cpp)
target_link_libraries(raw2pb user-iris rscan-iris gRPC::grpc++ vaisala-wr-common-dto::common-dto siglog ${Boost_LIBRARIES} m z lz4 ${PROTOBUF_LIBRARIES})

add_executable(raw2dm raw2pb.cpp)
set_target_properties(raw2dm PROPERTIES COMPILE_FLAGS "-DINTERFACE_TO_DM")
target_link_libraries(raw2dm user-iris rscan-iris gRPC::grpc++ vaisala-wr-common-dto::common-dto data-manager
        data-manager-iris siglog ${Boost_LIBRARIES} m z lz4 ${PROTOBUF_LIBRARIES})

add_executable(pb2raw pb2raw.cpp pbio.cpp pbio.hpp)
target_link_libraries(pb2raw user-iris rscan-iris  vaisala-wr-common-dto::common-dto siglog ${Boost_LIBRARIES} m z lz4 ${PROTOBUF_LIBRARIES})

add_executable(raw2pb_input_dto raw2pb_input_dto.cpp)
target_link_libraries(raw2pb_input_dto user-iris rscan-iris vaisala-wr-input-dto::input-dto siglog ${Boost_LIBRARIES} m z lz4 ${PROTOBUF_LIBRARIES})

install(TARGETS ${PIPE_NAMES} DESTINATION ${IRIS_PIPES} COMPONENT protobuf)
install(TARGETS ${PIPE_NAME_INPUT_DTO} DESTINATION ${IRIS_PIPES} COMPONENT protobuf-input-dto)
install(FILES ${CONF_FILES} DESTINATION ${IRIS_CONFIG_TMPL} COMPONENT protobuf)
