cmake_minimum_required(VERSION 3.15)
project(reforge_core VERSION 2.0.16 LANGUAGES CXX)

if(SKBUILD)
  set(BUILD_TESTING OFF CACHE BOOL "Disable native tests in Python wheels" FORCE)
  set(BUILD_SHARED_LIBS ON CACHE BOOL "Package shared native SDK libraries" FORCE)
endif()
include(CTest)

if(POLICY CMP0148)
  cmake_policy(SET CMP0148 NEW)
endif()

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(PYBIND11_FINDPYTHON ON CACHE BOOL "Use CMake FindPython for pybind11" FORCE)
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)

# Build the Python-independent foundation first so legacy SDK consumers can
# link its exported targets without recreating native implementations.
add_subdirectory(native)

if(SKBUILD)
  set(_reforge_core_native_build_shared_libs "${BUILD_SHARED_LIBS}")
  set(BUILD_SHARED_LIBS OFF)
endif()
add_subdirectory(reforge_core)
if(SKBUILD)
  set(BUILD_SHARED_LIBS "${_reforge_core_native_build_shared_libs}")
endif()
