cmake_minimum_required(VERSION 3.23)
set(PROJECT_ROOT ${CMAKE_CURRENT_LIST_DIR})
set(PROJECT_VERSION 0.6.0)
add_compile_definitions(PROJECT_ROOT_PATH="${PROJECT_ROOT}/")

# Stop the warning for gtest and corrosion in newer cmake versions
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
  cmake_policy(SET CMP0135 NEW)
endif()

project(
  ipbus
  VERSION ${PROJECT_VERSION}
)

# Corrosin
include(FetchContent)
FetchContent_Declare(
    Corrosion
    GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
    GIT_TAG 1499b14e4906a2890f5cee1547c8848db261753d
)
FetchContent_MakeAvailable(Corrosion)

# Google Test
find_package(GTest)
if (GTest_FOUND)
  message("Using system GTest")
else()
  message("Fetching GTest")
  include(FetchContent)
  FetchContent_Declare(
    googletest
    URL https://github.com/google/googletest/archive/063de7e9578f82b369302001269680b4b1553359.zip
  )
  set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
  FetchContent_MakeAvailable(googletest)
endif (GTest_FOUND)

include(GNUInstallDirs)
include(GenerateExportHeader)
include(CMakePackageConfigHelpers)

# Add bindings folder
add_subdirectory(ffi/c)
add_subdirectory(ffi/cpp)
