-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGTest.cmake
More file actions
22 lines (18 loc) · 842 Bytes
/
Copy pathGTest.cmake
File metadata and controls
22 lines (18 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Make an executable target with gtest support. Gtest and associated crap is automatically
# added, and the target installed to the test prefix.
#
# @param CUSTOM_MAIN Pass flag if you have defined your own main. Otherwise the default gtest
# main is used.
include(externals/GoogleTest)
function(add_gtest_executable TARGET)
set(flags CUSTOM_MAIN)
cmake_parse_arguments(gt "${flags}" "" "" ${ARGN})
add_test_executable(${TARGET} ${gt_UNPARSED_ARGUMENTS})
# Link in gmock's main function if we need to
# We need to do this first, as when they're static, the linker does things in order, and gmock_main
# depends on gmock
if(NOT "${gt_CUSTOM_MAIN}")
target_link_libraries(${TARGET} PRIVATE gmock_main)
endif()
target_link_libraries(${TARGET} PRIVATE gmock gtest)
endfunction()