cmake_minimum_required(VERSION 3.18...3.26 FATAL_ERROR)

project(FileDbDs VERSION 0.1.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

find_package(Tango)

add_library(tango_exfiledb src/parser.cpp src/database_tables.cpp src/filedb_device.cpp src/database_device.cpp)
target_link_libraries(tango_exfiledb PUBLIC Tango::Tango)
target_include_directories(tango_exfiledb PUBLIC include)

if (WIN32)
    target_compile_definitions(tango_exfiledb PUBLIC "NOMINMAX") 
endif()

add_library(FileDb::Lib ALIAS tango_exfiledb)

add_executable(FileDbDs src/main.cpp)
target_link_libraries(FileDbDs PRIVATE tango_exfiledb)

add_executable(FileDb::DeviceServer ALIAS FileDbDs)

if (BUILD_TESTING)
  find_package(Catch2 3.3.0 REQUIRED)

  add_executable(tests tests/parser.cpp tests/database_tables.cpp tests/filedb_backend.cpp)
  target_link_libraries(tests PRIVATE tango_exfiledb Catch2::Catch2WithMain)

  include(CTest)
  include(Catch)
  catch_discover_tests(tests)
endif()
