# Start of tes3mp addition
#
# tes3mp-wire: the TES3MP packet layer (components/openmw-mp). It does not depend on components/esm
# or on any other engine component: records cross the wire as the plain structs in
# Base/BaseWire.hpp.
project(Tes3mpWire)

find_package(RakNet REQUIRED)

file(GLOB_RECURSE TES3MP_WIRE_SOURCES CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
file(GLOB_RECURSE TES3MP_WIRE_HEADERS CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp)

# Packets/Player/PacketPlayerRegionAuthority.cpp is not compiled by the 0.8.1-layer build either:
# it includes a header that does not exist (PacketWorldRegionAuthority.hpp).
list(REMOVE_ITEM TES3MP_WIRE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Packets/Player/PacketPlayerRegionAuthority.cpp)

add_library(tes3mp-wire STATIC ${TES3MP_WIRE_SOURCES} ${TES3MP_WIRE_HEADERS})

target_include_directories(tes3mp-wire PUBLIC
    ${OpenMW_SOURCE_DIR}
    ${RakNet_INCLUDES}
)
target_link_libraries(tes3mp-wire PUBLIC ${RakNet_LIBRARY})

# Header-only Boost (crc, lexical_cast, any). No Boost library is linked.
if (TARGET Boost::headers)
    target_link_libraries(tes3mp-wire PUBLIC Boost::headers)
else ()
    target_include_directories(tes3mp-wire PUBLIC ${Boost_INCLUDE_DIR})
endif ()

set_target_properties(tes3mp-wire PROPERTIES
    CXX_STANDARD 20
    CXX_STANDARD_REQUIRED YES
)

if (MSVC)
    target_compile_definitions(tes3mp-wire PUBLIC _USE_MATH_DEFINES)
endif ()
# End of tes3mp addition
