# CMakeLists.txt for photon_c_wrapper
#
# This builds the C wrapper library that provides a stable C ABI
# for calling PhotonLibOS from Rust.

cmake_minimum_required(VERSION 3.14)

project(photon_c_wrapper LANGUAGES CXX)

# Build PhotonLibOS as a subdirectory
add_subdirectory(PhotonLibOS)

# Create the C wrapper library
add_library(photon_c_wrapper STATIC
    photon_c_wrapper.cpp
)

# Use the same C++ standard as PhotonLibOS
set_target_properties(photon_c_wrapper PROPERTIES
    CXX_STANDARD 17
    CXX_STANDARD_REQUIRED ON
    POSITION_INDEPENDENT_CODE ON
)

# Include PhotonLibOS headers
target_include_directories(photon_c_wrapper PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}/PhotonLibOS
    ${CMAKE_CURRENT_SOURCE_DIR}/PhotonLibOS/include
)

# Link against PhotonLibOS
target_link_libraries(photon_c_wrapper PRIVATE
    photon_static
)

# Install the wrapper library
install(TARGETS photon_c_wrapper
    ARCHIVE DESTINATION lib
)

install(FILES photon_c_wrapper.h
    DESTINATION include
)
