cmake_minimum_required(VERSION 3.15)
project(stackaroo_ffi_smoke_tests CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Set the path to the stackaroo crate
set(STACKAROO_ROOT "${CMAKE_SOURCE_DIR}/..")

# Fetch Corrosion to build Rust crates
include(FetchContent)

FetchContent_Declare(
    Corrosion
    GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
    GIT_TAG v0.5
)
FetchContent_MakeAvailable(Corrosion)

# Import the stackaroo Rust crate
corrosion_import_crate(
    MANIFEST_PATH "${STACKAROO_ROOT}/Cargo.toml"
    CRATES stackaroo
    FEATURES ffi
)

# Enable testing
enable_testing()

# Create the smoke tests executable
add_executable(smoke_tests main.cpp)
target_link_libraries(smoke_tests PRIVATE stackaroo)
target_include_directories(smoke_tests PRIVATE ${STACKAROO_ROOT})

# Add as a test
add_test(NAME smoke_tests COMMAND smoke_tests)

# Print configuration info
message(STATUS "stackaroo root: ${STACKAROO_ROOT}")
message(STATUS "stackaroo include: ${STACKAROO_INCLUDE_DIR}")
