# Tcp Server Plugin compilation
add_library(TcpServerPlugin SHARED
    TcpServerPlugin.cpp ${CMAKE_SOURCE_DIR}/src/IPC.cpp
)

include(ExternalProject)
ExternalProject_Add(socketscpp
    GIT_REPOSITORY    https://github.com/CJLove/sockets-cpp.git
    GIT_TAG           master
    UPDATE_COMMAND    ""
    PATCH_COMMAND     ""
    CONFIGURE_COMMAND ""
    BUILD_COMMAND     ""
    INSTALL_COMMAND   ""
    LOG_DOWNLOAD      ON
)

# Set include directories for socketscpp
ExternalProject_Get_Property(socketscpp source_dir)
set(SOCKETSCPP_INCLUDE_DIR ${source_dir}/include/sockets-cpp)

target_link_libraries(TcpServerPlugin nlohmann_json::nlohmann_json)
target_include_directories(TcpServerPlugin PUBLIC ${SOCKETSCPP_INCLUDE_DIR})

# Set the output directory for the plugins
set_target_properties(TcpServerPlugin PROPERTIES
    LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins
)


add_dependencies(TcpServerPlugin socketscpp)