cmake_minimum_required(VERSION 3.24 FATAL_ERROR) option(SKULLC_TESTS_WITH_SANITIZERS "Enable sanitizers for tests." ON) include(FetchContent) FetchContent_Declare(Catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_TAG v2.13.8 ) FetchContent_MakeAvailable(Catch2) FetchContent_Declare(nanopb GIT_REPOSITORY https://github.com/nanopb/nanopb.git GIT_TAG origin/master FIND_PACKAGE_ARGS ) FetchContent_GetProperties(nanopb) if (NOT nanopb_POPULATED) FetchContent_Populate(nanopb) endif () list(APPEND CMAKE_MODULE_PATH "${nanopb_SOURCE_DIR}/extra") find_package(Nanopb REQUIRED) if(SKULLC_TESTS_WITH_SANITIZERS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=address -fsanitize=undefined -fno-sanitize-recover") set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=address -fsanitize=undefined -fno-sanitize-recover") endif() add_executable(tests main.cpp ringbuffer.cpp packet.cpp parser.cpp button.cpp rand.cpp fixedpoint.cpp pixelbuffer.cpp pixelbuffer_effects.cpp function.cpp assert_ndebug.cpp assert.cpp enum_helpers.cpp bytes.cpp filters.cpp ) nanopb_generate_cpp(TARGET proto RELPATH nanopb nanopb/simple.proto) target_link_libraries(tests PUBLIC skullc::utility skullc::messaging skullc::peripherals Catch2::Catch2 proto ) set_target_properties(tests PROPERTIES CXX_STANDARD 23 ) list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/contrib) include(CTest) include(Catch) catch_discover_tests(tests)