diff --git a/.idea/cmake.xml b/.idea/cmake.xml index b035c90..4f2501f 100644 --- a/.idea/cmake.xml +++ b/.idea/cmake.xml @@ -2,8 +2,9 @@ - - + + + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 767fb55..b007d5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,7 +102,6 @@ option(CATCH_INSTALL_DOCS "Install documentation alongside library" OFF) option(CATCH_INSTALL_EXTRAS "Install extras alongside library" OFF) add_subdirectory(external/catch2) -add_subdirectory("Unit testing") set(COMPILE_FLAGS -pipe @@ -132,6 +131,17 @@ set(LINKER_FLAGS jemalloc ) +option(ENABLE_COVERAGE "Enabling coverage" OFF) + +if (${ENABLE_COVERAGE}) + message(STATUS "Coverage enabled") + list(APPEND COMPILE_FLAGS --coverage) + list(APPEND LINKER_OPTIONS --coverage) + list(APPEND LINKER_FLAGS gcov) +endif () + +add_subdirectory("Unit testing") + add_executable(BillySheet ${SOURCES}) target_include_directories(BillySheet PRIVATE include include/imgui external/ImFileDialog) diff --git a/Unit testing/CMakeLists.txt b/Unit testing/CMakeLists.txt index 45c423c..d2edbd9 100644 --- a/Unit testing/CMakeLists.txt +++ b/Unit testing/CMakeLists.txt @@ -2,33 +2,7 @@ cmake_minimum_required(VERSION 3.19 FATAL_ERROR) project(UnitTest CXX) -set(COMPILE_FLAGS - -pipe - -march=skylake # change to native or your architecture. - -mtune=skylake # same as above - -mrdseed # be careful about this, this is linked to the x86 architecture. - -mrdrnd # same as above - -Wall - -Wextra - -Wpedantic - # -Wpadded - -pedantic - -ffunction-sections - -fdata-sections - -fuse-ld=gold - -funroll-loops - -fdevirtualize-at-ltrans - -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free - ) -set(LINKER_OPTIONS - -Wl,--sort-common,--as-needed,--gc-sections,--strip-all - -fuse-ld=gold - -fdevirtualize-at-ltrans - ) - -set(LINKER_FLAGS - jemalloc - ) +include(../external/catch2/contrib/Catch.cmake) add_executable(UnitTest adummy.cpp characteristics_tests.cpp) @@ -37,11 +11,13 @@ set_target_properties(Catch2 UnitTest PROPERTIES CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF INTERPROCEDURAL_OPTIMIZATION ON -# UNITY_BUILD ON + # UNITY_BUILD ON ) - target_include_directories(UnitTest PRIVATE ${CMAKE_SOURCE_DIR}/include) target_compile_definitions(UnitTest PRIVATE ${DEF_COMP}) target_compile_options(UnitTest PRIVATE ${COMPILE_FLAGS}) target_link_options(UnitTest PRIVATE ${LINKER_OPTIONS}) target_link_libraries(UnitTest ${LINKER_FLAGS} Catch2 nlohmann_json::nlohmann_json) + +enable_testing() +catch_discover_tests(UnitTest WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} REPORTER junit OUTPUT_DIR ${CMAKE_SOURCE_DIR} OUTPUT_PREFIX cppspec- OUTPUT_SUFFIX .xml)