File tree Expand file tree Collapse file tree 5 files changed +42
-5
lines changed
Expand file tree Collapse file tree 5 files changed +42
-5
lines changed Original file line number Diff line number Diff line change 11cmake_minimum_required (VERSION 3.11)
22project (SortingAlgorithms LANGUAGES CXX)
33
4+ set (CMAKE_CXX_STANDARD 11)
5+ set (CMAKE_CXX_EXTENSIONS off )
6+ set (CMAKE_CXX_STANDARD_REQUIRED on )
7+
48include (cmake/ConfigureProjectTests.cmake)
59Core_ConfigureProjectTests()
10+
11+ include (cmake/ConfigureProjectBenchmark.cmake)
12+ Core_ConfigureProjectBenchmark()
13+
14+ add_library (${PROJECT_NAME} INTERFACE include /sorting_algorithms/sort .hpp)
15+ add_library (SortAlgorithmsLibrary ALIAS ${PROJECT_NAME} )
16+ target_include_directories (${PROJECT_NAME} INTERFACE
17+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include >
18+ $<INSTALL_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include >
19+ )
Original file line number Diff line number Diff line change 77
88#include < benchmark/benchmark.h>
99
10- #include " sort.hpp"
10+ #include < sorting_algorithms/ sort.hpp>
1111
1212struct SortFunc { enum type {
1313 bubble_sort,
Original file line number Diff line number Diff line change 1+ function (Core_ConfigureProjectBenchmark)
2+ include (FetchContent)
3+ set (BENCHMARK_ENABLE_TESTING off )
4+ FetchContent_Declare(
5+ GoogleBenchmark
6+ GIT_REPOSITORY https://github.com/google/benchmark.git
7+ GIT_TAG v1.6.1
8+ )
9+ FetchContent_MakeAvailable(GoogleBenchmark)
10+
11+ set (BenchmarkTargetName ${PROJECT_NAME} Benchmark)
12+
13+ add_executable (${BenchmarkTargetName} benchmark/sort_benchmark.cpp)
14+ target_link_libraries (${BenchmarkTargetName} PRIVATE
15+ benchmark::benchmark
16+ SortAlgorithmsLibrary
17+ )
18+ endfunction ()
Original file line number Diff line number Diff line change @@ -7,10 +7,15 @@ function(Core_ConfigureProjectTests)
77 )
88 FetchContent_MakeAvailable(Catch2)
99
10- add_executable (${PROJECT_NAME} Tests test /sort_test.cpp)
11- target_link_libraries (${PROJECT_NAME} Tests PRIVATE Catch2::Catch2)
10+ set (TargetName ${PROJECT_NAME} Tests)
11+
12+ add_executable (${TargetName} test /sort_test.cpp)
13+ target_link_libraries (${TargetName} PRIVATE
14+ Catch2::Catch2
15+ SortAlgorithmsLibrary
16+ )
1217
1318 include (CTest)
1419 include (${Catch2_SOURCE_DIR} /contrib/Catch.cmake)
15- catch_discover_tests(${PROJECT_NAME} Tests )
20+ catch_discover_tests(${TargetName} )
1621endfunction ()
Original file line number Diff line number Diff line change 77#define CATCH_CONFIG_MAIN
88#include " catch.hpp"
99
10- #include " sort.hpp"
10+ #include < sorting_algorithms/ sort.hpp>
1111
1212static std::mt19937 gen (std::chrono::high_resolution_clock::now().time_since_epoch().count());
1313
You can’t perform that action at this time.
0 commit comments