new gtest

This commit is contained in:
2023-03-16 09:34:34 +03:00
parent 504fc5c896
commit 650dadc347
5 changed files with 25 additions and 148 deletions

View File

@@ -1,28 +1,34 @@
include(DownloadGTest)
cmake_minimum_required(VERSION 3.14)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/suppr.txt ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
set(CMAKE_CXX_STANDARD 11)
macro(pip_test NAME LIBS)
cmake_policy(SET CMP0135 NEW)
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/58d77fa8070e8cec2dc1ed015d66b454c8d78850.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
enable_testing()
include(GoogleTest)
macro(pip_test NAME)
file(GLOB _CPPS "${NAME}/*.cpp")
file(GLOB _HDRS "${NAME}/*.h")
set(_target pip_${NAME}_test)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PIP_ROOT_BINARY_DIR}")
add_executable(${_target} ${_CPPS} ${_HDRS})
if (NOT WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${_target} PRIVATE -fsanitize=address,undefined)
target_link_options(${_target} PRIVATE -fsanitize=address,undefined)
target_link_libraries(${_target} asan)
endif()
target_link_libraries(${_target} pip ${LIBS} gtest_main gmock_main)
add_test(NAME ${_target} COMMAND tests)
add_custom_target(${_target}_perform ALL
COMMAND ${CMAKE_COMMAND} -E env "LSAN_OPTIONS=suppressions=suppr.txt" $<TARGET_FILE:${_target}>)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY)
target_link_libraries(${_target} pip ${ARGN} gtest_main)
gtest_discover_tests(${_target})
list(APPEND PIP_TESTS_LIST "${NAME}")
set(PIP_TESTS_LIST ${PIP_TESTS_LIST} PARENT_SCOPE)
endmacro()
pip_test(concurrent "")
pip_test(math "")
pip_test(core "")
pip_test(piobject "")
#pip_test(concurrent)
pip_test(math)
pip_test(core)
pip_test(piobject)