forked from facebook/mvfst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuicTest.cmake
73 lines (59 loc) · 2.01 KB
/
QuicTest.cmake
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
include(CTest)
if(BUILD_TESTS)
find_package(GMock 1.10.0 MODULE REQUIRED)
find_package(GTest 1.10.0 MODULE REQUIRED)
endif()
function(quic_add_test)
if(NOT BUILD_TESTS)
return()
endif()
set(options)
set(one_value_args TARGET WORKING_DIRECTORY PREFIX)
set(multi_value_args SOURCES DEPENDS INCLUDES EXTRA_ARGS)
cmake_parse_arguments(PARSE_ARGV 0 QUIC_TEST "${options}" "${one_value_args}" "${multi_value_args}")
if(NOT QUIC_TEST_TARGET)
message(FATAL_ERROR "The TARGET parameter is mandatory.")
endif()
if(NOT QUIC_TEST_SOURCES)
set(QUIC_TEST_SOURCES "${QUIC_TEST_TARGET}.cpp")
endif()
add_executable(${QUIC_TEST_TARGET}
"${QUIC_TEST_SOURCES}"
# implementation of 'main()' that calls folly::init
"${QUIC_FBCODE_ROOT}/quic/common/test/TestMain.cpp"
)
set_property(TARGET ${QUIC_TEST_TARGET} PROPERTY ENABLE_EXPORTS true)
target_include_directories(${QUIC_TEST_TARGET} PUBLIC
"${QUIC_TEST_INCLUDES}"
${LIBGMOCK_INCLUDE_DIR}
${LIBGTEST_INCLUDE_DIRS}
${QUIC_EXTRA_INCLUDE_DIRECTORIES}
)
target_compile_definitions(${QUIC_TEST_TARGET} PUBLIC
${LIBGMOCK_DEFINES}
)
target_link_libraries(${QUIC_TEST_TARGET} PUBLIC
"${QUIC_TEST_DEPENDS}"
${LIBGMOCK_LIBRARIES}
${GLOG_LIBRARY}
)
# Per https://github.com/facebookincubator/mvfst/pull/9, disable some warnings
# in the tests that come from -Wextra in _QUIC_BASE_COMPILE_OPTIONS.
target_compile_options(
${QUIC_TEST_TARGET} PRIVATE
${_QUIC_BASE_COMPILE_OPTIONS}
"-Wno-sign-compare"
"-Wno-inconsistent-missing-override"
)
gtest_add_tests(TARGET ${QUIC_TEST_TARGET}
EXTRA_ARGS "${QUIC_TEST_EXTRA_ARGS}"
WORKING_DIRECTORY ${QUIC_TEST_WORKING_DIRECTORY}
TEST_PREFIX ${QUIC_TEST_PREFIX}
TEST_LIST QUIC_TEST_CASES
)
set_tests_properties(${QUIC_TEST_CASES} PROPERTIES TIMEOUT 120)
endfunction()