John Wellbelove 363a3e2dab Fix test array sizes
C++14 compiler compatibility

Updated test run scripts

Changed some ETL_ASSERT macros to ETL_ASSERT_OR_RETURN

Changed unit test macros for C++20 compaibility

Updated test run scripts

Updated CMake files to allow C++ standard selection

Replaced ETL_ASSERT_AND_RETURN with ETL_ASSERT_OR_RETURN

Updated C++14 & C++20 unit test compatibility

Changed native char8_t check

Added optional optimisation argument to bash script
2023-04-02 11:06:43 +01:00

81 lines
2.3 KiB
CMake

cmake_minimum_required(VERSION 3.5.0)
project(etl_error_handler_unit_tests)
add_definitions(-DETL_DEBUG)
add_definitions(-DETL_THROW_EXCEPTIONS)
include_directories(${PROJECT_SOURCE_DIR}/../../../include)
set(TEST_SOURCE_FILES
test_error_handler.cpp
)
add_executable(etl_tests
${TEST_SOURCE_FILES}
)
if (ETL_CXX_STANDARD MATCHES "98")
message(STATUS "Compiling for C++98")
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 98)
elseif (ETL_CXX_STANDARD MATCHES "03")
message(STATUS "Compiling for C++98")
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 98)
elseif (ETL_CXX_STANDARD MATCHES "11")
message(STATUS "Compiling for C++11")
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 11)
elseif (ETL_CXX_STANDARD MATCHES "14")
message(STATUS "Compiling for C++14")
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 14)
elseif (ETL_CXX_STANDARD MATCHES "17")
message(STATUS "Compiling for C++17")
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 17)
else()
message(STATUS "Compiling for C++20")
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 20)
endif()
if (ETL_OPTIMISATION MATCHES "-O1")
message(STATUS "Compiling with -O1 optimisations")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1")
endif()
if (ETL_OPTIMISATION MATCHES "-O2")
message(STATUS "Compiling with -O2 optimisations")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
endif()
if (ETL_OPTIMISATION MATCHES "-O3")
message(STATUS "Compiling with -O3 optimisations")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
endif()
target_include_directories(etl_tests
PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)
if ((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
target_compile_options(etl_tests
PRIVATE
-fsanitize=address,undefined,bounds
-fno-omit-frame-pointer
-Wall
-Wextra
-Werror
)
target_link_options(etl_tests
PRIVATE
-fsanitize=address,undefined,bounds
)
endif ()
# Enable the 'make test' CMake target using the executable defined above
add_test(etl_error_handler_unit_tests etl_tests)
# Since ctest will only show you the results of the single executable
# define a target that will output all of the failing or passing tests
# as they appear from UnitTest++
add_custom_target(test_verbose COMMAND ${CMAKE_CTEST_COMMAND} --verbose)