cmake_minimum_required(VERSION 3.8)
project(RTNeural)

set(CMAKE_CXX_STANDARD 17)
if(MSVC)
    set(CMAKE_CXX_FLAGS "/Ox /EHsc")
else()
    set(CMAKE_CXX_FLAGS "-O3")
endif()

add_subdirectory(RTNeural)

# select library backend
option(RTNEURAL_EIGEN "Use Eigen library for vector operations" OFF)
option(RTNEURAL_XSIMD "Use xsimd library for vector operations" OFF)
option(RTNEURAL_ACCELERATE "Use Accelerate library for vector operations (Apple only)" OFF)
option(RTNEURAL_STL "Use STL for all operations" OFF)
if(RTNEURAL_EIGEN)
    message(STATUS "RTNeural - Using Eigen backend")
    target_compile_definitions(RTNeural PUBLIC USE_EIGEN=1)
elseif(RTNEURAL_XSIMD)
    message(STATUS "RTNeural - Using xsimd backend")
    target_compile_definitions(RTNeural PUBLIC USE_XSIMD=1)
elseif(RTNEURAL_ACCELERATE)
    if(NOT APPLE)
        message(FATAL_ERROR "Accelerate is only supported on Apple platforms!")
    endif()
    message(STATUS "RTNeural - Using Accelerate backend")
    target_compile_definitions(RTNeural PUBLIC USE_ACCELERATE=1)
elseif(RTNEURAL_STL)
    message(STATUS "RTNeural - Using STL backend")
else()
    message(STATUS "RTNeural - Using Eigen backend (Default)")
    target_compile_definitions(RTNeural PUBLIC USE_EIGEN=1)
endif()

option(BUILD_TESTS "Build RTNeural accuracy tests" OFF)
if(BUILD_TESTS)
    message("-- RTNeural -- Configuring tests...")
    add_subdirectory(tests)
endif()

option(BUILD_BENCH "Build RTNeural benchmarks" OFF)
if(BUILD_BENCH)
    message("-- RTNeural -- Configuring benchmarks...")
    add_subdirectory(bench)
endif()
