# src/ — recurse every source subdirectory (each attaches its own translation
# units to mlx-magic-lib), then build the product binary from main.cpp. src/ has
# NO lib sources of its own: main.cpp is the executable, not a library object.
add_subdirectory(device)
add_subdirectory(tensor)
add_subdirectory(ops)
add_subdirectory(util)
add_subdirectory(tokenize)
add_subdirectory(infer)
add_subdirectory(arch)
add_subdirectory(model)
add_subdirectory(server)
add_subdirectory(kernels)

# The product binary. mlxm_force_load keeps the lib's static Registrar objects
# (tokenize/arch self-registration) from being dead-stripped.
add_executable(mlx-magic-server main.cpp)
target_link_libraries(mlx-magic-server PRIVATE mlx-magic-lib)
mlxm_force_load(mlx-magic-server)
# Emit to build/ root (not build/src/) so build.command + install.command find it
# at the path they expect — the executable moving dirs must not break deploy.
set_target_properties(mlx-magic-server PROPERTIES
    RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
install(TARGETS mlx-magic-server DESTINATION bin)
