cmake_minimum_required(VERSION 3.13)
project(can_sensor C)

set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)

add_library(can_sensor STATIC can_sensor.c)
target_include_directories(can_sensor PUBLIC .)

if(MSVC)
    target_compile_options(can_sensor PRIVATE /W4)
else()
    target_compile_options(can_sensor PRIVATE -Wall -Wextra -Wpedantic)
endif()

option(CAN_SENSOR_BUILD_TESTS "Собирать тесты транспорта CAN sensor" ON)
if(CAN_SENSOR_BUILD_TESTS)
    enable_testing()
    add_executable(test_can_sensor tests/test_can_sensor.c)
    target_link_libraries(test_can_sensor PRIVATE can_sensor)
    add_test(NAME can_sensor COMMAND test_can_sensor)
endif()
