cmake_minimum_required(VERSION 3.16)
set(PROJECT_NAME scriptcommand)
project(${PROJECT_NAME})
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

OPTION(BUILD_TESTS "Build the script-command test suite" ON)

find_package(glaze)

if (!glaze_FOUND)
	include(Glaze)
	checkout_glaze()
endif()

add_library(vicinae-scriptcommand STATIC src/script-command.cpp)
add_library(vicinae::scriptcommand ALIAS vicinae-scriptcommand)
set(PROJECT_NAME vicinae-scriptcommand)
target_include_directories(${PROJECT_NAME} PUBLIC .)
target_link_libraries(${PROJECT_NAME} PUBLIC glaze::glaze)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_23)

if (BUILD_TESTS)
	set(TEST_TARGET scriptcommand-tests)
	find_package(Catch2 3 REQUIRED)
	add_compile_definitions(FIXTURE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/fixtures")
	add_executable(${TEST_TARGET} tests/main.cpp tests/failure.cpp tests/edge-cases.cpp tests/time-parsing.cpp tests/argument-validation.cpp tests/fields.cpp tests/comment-styles.cpp)
	target_link_libraries(${TEST_TARGET} PRIVATE Catch2::Catch2WithMain ${PROJECT_NAME})
	target_include_directories(${TEST_TARGET} PRIVATE .)
endif()
