# AlphaSDK — C/C++ client.
#
# The library is two files; this exists so "add_subdirectory(AlphaSDK/c)" works
# in a normal CMake project and so CI has something to build.
#
#   cmake -S . -B build && cmake --build build
#   cmake --build build --target alpha_quickstart   # the example
#
# ⚠️ C99, not C11 or gnu99. Unreal and older MSVC toolchains both compile
# third-party C at this level, and a feature that only exists above it is a
# build failure on the machine you cannot reach.

cmake_minimum_required(VERSION 3.10)
project(alpha_sdk C CXX)

set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)

find_package(CURL REQUIRED)

add_library(alpha_sdk STATIC src/alpha_sdk.c)
target_include_directories(alpha_sdk PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(alpha_sdk PUBLIC CURL::libcurl)

if(MSVC)
  target_compile_options(alpha_sdk PRIVATE /W4)
  # sprintf into a checked, fixed buffer is deliberate here; the "safe" variants
  # are MSVC-only and this file has to compile on four toolchains.
  target_compile_definitions(alpha_sdk PRIVATE _CRT_SECURE_NO_WARNINGS)
else()
  target_compile_options(alpha_sdk PRIVATE -Wall -Wextra -Wpedantic)
endif()

# The C++ wrapper is header-only — this target exists purely to prove it still
# compiles as C++ when the C header changes.
add_executable(alpha_quickstart EXCLUDE_FROM_ALL examples/quickstart.c)
target_link_libraries(alpha_quickstart PRIVATE alpha_sdk)

add_executable(alpha_quickstart_cpp EXCLUDE_FROM_ALL examples/quickstart.cpp)
set_property(TARGET alpha_quickstart_cpp PROPERTY CXX_STANDARD 11)
target_link_libraries(alpha_quickstart_cpp PRIVATE alpha_sdk)
