diff --git a/unbench/CMakeLists.txt b/unbench/CMakeLists.txt index 21cadc2..0c19ac4 100644 --- a/unbench/CMakeLists.txt +++ b/unbench/CMakeLists.txt @@ -4,31 +4,36 @@ cmake_minimum_required(VERSION 3.11 FATAL_ERROR) project(ecs.hpp.unbench) # -# google benchmark -# - -set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE) - -include(FetchContent) -FetchContent_Declare( - gbench - GIT_REPOSITORY https://github.com/google/benchmark) - -FetchContent_GetProperties(gbench) -if(NOT gbench_POPULATED) - FetchContent_Populate(gbench) - add_subdirectory(${gbench_SOURCE_DIR} ${gbench_BINARY_DIR}) -endif() - -# -# benchmark executable +# executable # file(GLOB UNBENCH_SOURCES "*.cpp" "*.hpp") add_executable(${PROJECT_NAME} ${UNBENCH_SOURCES}) +target_link_libraries(${PROJECT_NAME} ecs.hpp) -target_link_libraries(${PROJECT_NAME} - benchmark_main - ecs.hpp) +target_compile_options(${PROJECT_NAME} + PRIVATE + $<$: + /W4> + PRIVATE + $<$,$,$>: + -Wall -Wextra -Wpedantic>) add_test(${PROJECT_NAME} ${PROJECT_NAME}) + +# +# google/benchmark +# + +include(FetchContent) +FetchContent_Declare( + google_benchmark + GIT_REPOSITORY https://github.com/google/benchmark) + +FetchContent_GetProperties(google_benchmark) +if(NOT google_benchmark_POPULATED) + FetchContent_Populate(google_benchmark) + set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE) + add_subdirectory(${google_benchmark_SOURCE_DIR} ${google_benchmark_BINARY_DIR}) + target_link_libraries(${PROJECT_NAME} benchmark_main) +endif() diff --git a/unbench/ecs_join_bench.cpp b/unbench/ecs_join_bench.cpp index df40d5a..cb9fbc3 100644 --- a/unbench/ecs_join_bench.cpp +++ b/unbench/ecs_join_bench.cpp @@ -7,5 +7,5 @@ #include "bench_base.hpp" using namespace ecs_hpp_unbench; -#include "ecs.hpp" +#include namespace ecs = ecs_hpp; diff --git a/untests/CMakeLists.txt b/untests/CMakeLists.txt index c6f7633..35b1ba9 100644 --- a/untests/CMakeLists.txt +++ b/untests/CMakeLists.txt @@ -1,20 +1,11 @@ # 3.11 version is required for `FetchContent` cmake_minimum_required(VERSION 3.11 FATAL_ERROR) -project(flat.hpp.untests) +project(ecs.hpp.untests) -set(CATCH_BUILD_TESTING OFF CACHE BOOL "" FORCE) - -include(FetchContent) -FetchContent_Declare( - catch2 - GIT_REPOSITORY https://github.com/catchorg/catch2) - -FetchContent_GetProperties(catch2) -if(NOT catch2_POPULATED) - FetchContent_Populate(catch2) - add_subdirectory(${catch2_SOURCE_DIR} ${catch2_BINARY_DIR}) -endif() +# +# coverage +# option(BUILD_WITH_COVERAGE "Build with coverage" OFF) if(BUILD_WITH_COVERAGE AND (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")) @@ -24,11 +15,14 @@ if(BUILD_WITH_COVERAGE AND (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")) set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} ${COVERAGE_FLAGS}") endif() +# +# executable +# + file(GLOB UNTESTS_SOURCES "*.cpp" "*.hpp") add_executable(${PROJECT_NAME} ${UNTESTS_SOURCES}) -target_link_libraries(${PROJECT_NAME} - Catch2 - ecs.hpp) +target_link_libraries(${PROJECT_NAME} ecs.hpp) + target_compile_options(${PROJECT_NAME} PRIVATE $<$: @@ -36,4 +30,21 @@ target_compile_options(${PROJECT_NAME} PRIVATE $<$,$,$>: -Wall -Wextra -Wpedantic>) + add_test(${PROJECT_NAME} ${PROJECT_NAME}) + +# +# catchorg/catch2 +# + +include(FetchContent) +FetchContent_Declare( + catchorg_catch2 + GIT_REPOSITORY https://github.com/catchorg/catch2) + +FetchContent_GetProperties(catchorg_catch2) +if(NOT catchorg_catch2_POPULATED) + FetchContent_Populate(catchorg_catch2) + target_include_directories(${PROJECT_NAME} + PRIVATE ${catchorg_catch2_SOURCE_DIR}/single_include) +endif() diff --git a/untests/catch_main.cpp b/untests/catch_main.cpp index daf100a..172f4d3 100644 --- a/untests/catch_main.cpp +++ b/untests/catch_main.cpp @@ -5,5 +5,4 @@ ******************************************************************************/ #define CATCH_CONFIG_MAIN -#define CATCH_CONFIG_FAST_COMPILE #include diff --git a/untests/ecs_tests.cpp b/untests/ecs_tests.cpp index 40240eb..dbc87eb 100644 --- a/untests/ecs_tests.cpp +++ b/untests/ecs_tests.cpp @@ -4,7 +4,6 @@ * Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) ******************************************************************************/ -#define CATCH_CONFIG_FAST_COMPILE #include #include