-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUseCppUTest.cmake
More file actions
40 lines (33 loc) · 1.06 KB
/
UseCppUTest.cmake
File metadata and controls
40 lines (33 loc) · 1.06 KB
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
include(CMakeParseArguments)
include(CTest)
set(_CMAKE_SCRIPT_PATH ${CMAKE_CURRENT_LIST_DIR})
find_package(CppUTest REQUIRED)
function(add_unit_test)
set(oneValueArgs TARGET)
set(multiValueArgs SOURCES LIBRARIES)
cmake_parse_arguments(ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(ut_target "test-${ARGS_TARGET}")
if(NOT WITH_TESTS)
# skip if testing is not enabled or cpputest is not found
message(STATUS "UT disabled. Skipping test target: ${ut_target} ... ")
return()
endif()
# include paths and setup test target
include_directories(${CPPUTEST_INCLUDE_DIRS})
include_directories(${CPPUTEST_EXT_INCLUDE_DIRS})
add_executable(
${ut_target}
${ARGS_SOURCES}
)
target_link_libraries(
${ut_target}
${CPPUTEST_LIBRARIES}
${CPPUTEST_EXT_LIBRARIES}
${ARGS_LIBRARIES}
)
# also add as a test to ctest
add_test(
NAME ${ut_target}
COMMAND ${ut_target} -v
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
endfunction(add_unit_test)