-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
56 lines (47 loc) · 1.66 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
include(CheckCXXCompilerFlag)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
# CHECK_CXX_COMPILER_FLAG actually check preprocessor flag...
set(SAFE_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS "-fsanitize=address")
CHECK_CXX_COMPILER_FLAG( -DDummy FLAG_SANITIZE_ADDRESS)
set(CMAKE_REQUIRED_FLAGS ${SAFE_CMAKE_REQUIRED_FLAGS})
if(FLAG_SANITIZE_ADDRESS)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address")
endif()
set(TESTS
simple
test_cover
test_txn
test_whiteout
test_sandwich
test_corners
)
foreach(test ${TESTS})
add_executable(${test} ${test}.cpp)
target_link_libraries(${test} ${GTEST_BOTH_LIBRARIES} ${LevelDB_LIBRARIES})
if(FAST_CHECK)
add_test(${test} ${test})
else()
GTEST_ADD_TESTS(${test} "" AUTO)
endif()
add_custom_target(check-disabled-${test}
COMMAND ${test} --gtest_also_run_disabled_tests --gtest_filter=*.DISABLED_*
DEPENDS ${test}
)
add_dependencies(check-disabled check-disabled-${test})
endforeach()
# a bit of magic to automatically reload generated list of tests
if(NOT FAST_CHECK)
add_custom_command(
OUTPUT .refresh_tests
COMMAND ${CMAKE_MAKE_PROGRAM} rebuild_cache
COMMAND touch .refresh_tests
DEPENDS ${TESTS}.cpp
)
add_custom_target(refresh_tests DEPENDS .refresh_tests)
add_dependencies(depend-check refresh_tests ${TESTS})
endif()
add_dependencies(depend-check ${TESTS})
# also lets check symbols duplications by linking all tests together
add_executable(all-tests ${TESTS}.cpp)
target_link_libraries(all-tests ${GTEST_BOTH_LIBRARIES} ${LevelDB_LIBRARIES})