# mcts_libtorch — pybind11 extension for callback-based C++ MCTS
# Requires: Torch, pybind11 (provided by parent CMakeLists)

# Header-only interface target (templates live in headers)
add_library(mcts_libtorch_core INTERFACE)
target_include_directories(mcts_libtorch_core INTERFACE
    ${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(mcts_libtorch_core INTERFACE ${TORCH_LIBRARIES})

# Static library for the non-template search.cpp
add_library(mcts_libtorch_search STATIC src/search.cpp)
target_include_directories(mcts_libtorch_search PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(mcts_libtorch_search PUBLIC
    mcts_libtorch_core
    ${TORCH_LIBRARIES}
)
set_property(TARGET mcts_libtorch_search PROPERTY POSITION_INDEPENDENT_CODE ON)
target_compile_options(mcts_libtorch_search PRIVATE ${TORCH_CXX_FLAGS})

# pybind11 Python extension
pybind11_add_module(mcts_libtorch src/bindings.cpp)
target_link_libraries(mcts_libtorch PRIVATE
    mcts_libtorch_search
    ${TORCH_LIBRARIES}
)

message(STATUS "[mcts_libtorch] LibTorch ${Torch_VERSION}, pybind11 ${pybind11_VERSION}")
