cmake: Enable googletest unit tests (#1720)

Also don't inherit compile warnings from wpiutil

There's not a good way to disable inherited compiler flags.
This commit is contained in:
Peter Johnson
2019-06-23 12:44:28 -07:00
committed by GitHub
parent 223d47af0e
commit 372ca4f456
11 changed files with 140 additions and 11 deletions

View File

@@ -0,0 +1,14 @@
include(CompileWarnings)
macro(wpilib_add_test name srcdir)
file(GLOB_RECURSE test_src ${srcdir}/*.cpp)
add_executable(${name}_test ${test_src})
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 /wd4251 /wd4101)
endif()
add_test(NAME ${name} COMMAND ${name}_test)
endmacro()