-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
36 lines (34 loc) · 1.33 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
cmake_minimum_required(VERSION 3.16)
project(d_ary_heap)
set(CMAKE_CXX_STANDARD 17)
# 添加单元测试。
find_package(GTest)
if(GTest_FOUND)
enable_testing()
include(GoogleTest)
file(GLOB TEST_SRC CONFIGURE_DEPENDS "test/*.t.cpp")
add_executable(test_d_ary_heap ${TEST_SRC})
target_link_libraries(test_d_ary_heap gmock gtest pthread)
gtest_discover_tests(test_d_ary_heap XML_OUTPUT_DIR
${CMAKE_CURRENT_BINARY_DIR}/Testing)
message(STATUS "GTest found, test cases can be executed.")
else(GTest_FOUND)
message(WARNING "Unable to find GTest!")
endif(GTest_FOUND)
# 添加benchmark用例。
find_package(benchmark)
if(benchmark_FOUND)
set(BENCHMARK_ENABLE_TESTING OFF)
file(GLOB_RECURSE ALL_BENCH_SRC "bench/*.bench.cpp")
include_directories(${benchmark_LIBRARIES})
foreach(BENCH_SRC ${ALL_BENCH_SRC})
get_filename_component(BENCH_EXEC ${BENCH_SRC} NAME_WE)
set(TARGET_NAME bench_${BENCH_EXEC})
add_executable(${TARGET_NAME} ${BENCH_SRC})
set_target_properties(${TARGET_NAME} PROPERTIES OUTPUT_NAME ${BENCH_EXEC})
target_link_libraries(${TARGET_NAME} benchmark::benchmark pthread)
endforeach()
message(STATUS "Google benchmark found, benchmarking can be implemented.")
else(benchmark_FOUND)
message(WARNING "Unable to find Google benchmark!")
endif(benchmark_FOUND)