# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt

if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
  # warning level 4
  add_compile_options(/W4)
endif()

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

if(NOT TARGET tests)
  add_custom_target(tests)
endif()

set(PREFIX "boost_circular_buffer_")
set(LINK_LIBRARIES Boost::circular_buffer)
set(COMPILE_FEATURES cxx_std_11)

function(boost_circular_buffer_add_test name source)
  set(pname "${PREFIX}${name}")
  add_executable(${pname} ${source})
  target_link_libraries(${pname} PRIVATE ${LINK_LIBRARIES})
  target_compile_features(${pname} PRIVATE ${COMPILE_FEATURES})
  add_test(NAME ${pname} COMMAND ${pname})
  add_dependencies(tests ${pname})
endfunction()

#

boost_circular_buffer_add_test(base_test                  base_test.cpp)
boost_circular_buffer_add_test(constant_erase_test        constant_erase_test.cpp)
boost_circular_buffer_add_test(soft_iterator_invalidation soft_iterator_invalidation.cpp)
boost_circular_buffer_add_test(space_optimized_test       space_optimized_test.cpp)
