mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
36 lines
1.3 KiB
CMake
36 lines
1.3 KiB
CMake
include(CompileWarnings)
|
|
|
|
macro(wpilib_add_test name srcdir)
|
|
file(GLOB_RECURSE test_src ${srcdir}/*.cpp)
|
|
add_executable(${name}_test ${test_src})
|
|
set_property(TARGET ${name}_test PROPERTY FOLDER "tests")
|
|
wpilib_target_warnings(${name}_test)
|
|
if(BUILD_SHARED_LIBS)
|
|
target_compile_definitions(${name}_test PRIVATE -DGTEST_LINKED_AS_SHARED_LIBRARY)
|
|
endif()
|
|
if(MSVC)
|
|
target_compile_options(${name}_test PRIVATE /wd4101 /wd4251)
|
|
endif()
|
|
add_test(NAME ${name} COMMAND ${name}_test)
|
|
endmacro()
|
|
|
|
macro(wpilib_add_test_catch2 name)
|
|
set(wpilib_catch2_test_src)
|
|
foreach(src ${ARGN})
|
|
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${src}")
|
|
file(GLOB_RECURSE wpilib_catch2_dir_src ${src}/*.cpp)
|
|
list(APPEND wpilib_catch2_test_src ${wpilib_catch2_dir_src})
|
|
else()
|
|
list(APPEND wpilib_catch2_test_src ${src})
|
|
endif()
|
|
endforeach()
|
|
add_executable(${name}_test ${wpilib_catch2_test_src})
|
|
set_property(TARGET ${name}_test PROPERTY FOLDER "tests")
|
|
wpilib_target_warnings(${name}_test)
|
|
target_link_libraries(${name}_test catch2)
|
|
catch_discover_tests(${name}_test)
|
|
if(MSVC)
|
|
target_compile_options(${name}_test PRIVATE /wd4101 /wd4251 /utf-8)
|
|
endif()
|
|
endmacro()
|