1
- cmake_minimum_required (VERSION 3.7 )
2
- project (radr_benchmark CXX)
1
+ cmake_minimum_required (VERSION 3.12 )
2
+ project (radr_test_benchmark CXX)
3
3
4
4
include (FetchContent)
5
5
@@ -8,14 +8,12 @@ include(FetchContent)
8
8
# ----------------------------------------------------------------------------
9
9
10
10
message (STATUS "Beginning to configure RADR micro benchmarks..." )
11
+ include (../radr-test .cmake)
11
12
12
13
if (CMAKE_BUILD_TYPE AND NOT ("${CMAKE_BUILD_TYPE} " STREQUAL "Release" ))
13
14
message (WARNING "Benchmarks should typically be built in Release mode! [build type = ${CMAKE_BUILD_TYPE} ]" )
14
15
endif ()
15
16
16
- set (CMAKE_CXX_STANDARD 20)
17
- set (CMAKE_CXX_STANDARD_REQUIRED TRUE )
18
-
19
17
# ----------------------------------------------------------------------------
20
18
# Options
21
19
# ----------------------------------------------------------------------------
@@ -26,12 +24,7 @@ option(RADR_BENCHMARK_ALIGN_LOOPS "Pass -falign-loops=32 to the benchmark builds
26
24
# Paths to folders.
27
25
# ----------------------------------------------------------------------------
28
26
29
- find_path (RADR_BASE_DIR
30
- NAMES include /radr/rad/as_const.hpp
31
- HINTS "${CMAKE_CURRENT_LIST_DIR} /../../" )
32
- set (RADR_INCLUDE_DIR "${RADR_BASE_DIR} /include/" )
33
- set (RADR_TEST_INCLUDE_DIR "${RADR_BASE_DIR} /tests/include/" )
34
- set (RADR_UNIT_TESTS_SRC "${RADR_BASE_DIR} /tests/benchmark/" )
27
+ set (RADR_BENCHMARKS_DIR "${RADR_CLONE_DIR} /tests/benchmark/" )
35
28
36
29
# ----------------------------------------------------------------------------
37
30
# Components and dependencies
@@ -54,47 +47,26 @@ FetchContent_MakeAvailable(googlebenchmark)
54
47
# ----------------------------------------------------------------------------
55
48
56
49
add_library (radr_benchmark INTERFACE )
57
- target_compile_options (radr_benchmark INTERFACE "-pedantic" "-Wall" "-Wextra" "-Werror" )
58
50
target_link_libraries (radr_benchmark INTERFACE "pthread" benchmark::benchmark_main)
59
- target_include_directories (radr_benchmark INTERFACE "${RADR_INCLUDE_DIR} " "${RADR_TEST_INCLUDE_DIR} " )
60
51
add_library (radr::test ::benchmark ALIAS radr_benchmark)
61
52
62
53
if (RADR_BENCHMARK_ALIGN_LOOPS)
63
54
target_compile_options (radr_benchmark INTERFACE "-falign-loops=32" )
64
55
endif ()
65
56
66
- # ----------------------------------------------------------------------------
67
- # Test target macro
68
- # ----------------------------------------------------------------------------
69
-
70
- macro (radr_test unit_test_cpp)
71
- get_filename_component (target_dir "${unit_test_cpp} " DIRECTORY )
72
- get_filename_component (target "${unit_test_cpp} " NAME_WLE)
73
-
74
- add_executable (${target} "${RADR_UNIT_TESTS_SRC} /${unit_test_cpp} " )
75
- target_link_libraries (${target} radr::test ::benchmark)
76
-
77
- file (MAKE_DIRECTORY ${target_dir} )
78
- set_target_properties (${target} PROPERTIES
79
- RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /${target_dir} " )
80
-
81
- add_test (NAME "${target_dir} /${target} " COMMAND "${target_dir} /${target} " )
82
-
83
- unset (target )
84
- unset (target_dir)
85
- endmacro ()
86
-
87
57
# ----------------------------------------------------------------------------
88
58
# Start generating tests
89
59
# ----------------------------------------------------------------------------
90
60
91
61
file (GLOB_RECURSE ENTRIES
92
- RELATIVE ${RADR_BASE_DIR} /tests/benchmark
93
- "${RADR_UNIT_TESTS_SRC } /[!.]*cpp" )
62
+ RELATIVE ${RADR_BENCHMARKS_DIR}
63
+ "${RADR_BENCHMARKS_DIR } /[!.]*cpp" )
94
64
95
65
foreach (ENTRY ${ENTRIES} )
96
- message (STATUS ${ENTRY} )
97
- radr_test(${ENTRY} )
66
+ radr_add_test(${ENTRY} )
67
+ get_filename_component (target "${ENTRY} " NAME_WLE)
68
+ message (STATUS "Adding benchmark target '${target} ' for file ${ENTRY} " )
69
+ target_link_libraries (${target} radr::test ::benchmark)
98
70
endforeach ()
99
71
100
72
message (STATUS "Configuring RADR micro benchmarks DONE." )
0 commit comments