範例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| find_package(Threads REQUIRED)
include(FetchContent) FetchContent_Declare( googletest GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG 52eb8108c5bdec04579160ae17225d66034bd723 ) FetchContent_MakeAvailable(googletest) enable_testing()
add_subdirectory(testplate)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| include(GoogleTest) file(GLOB SRCS *.cpp) add_executable(testplate ${SRCS})
target_link_libraries(testplate gtest_main libtestplate )
gtest_add_tests(TARGET testplate TEST_SUFFIX .noArgs TEST_LIST noArgsTests )
set_tests_properties(${noArgsTests} PROPERTIES TIMEOUT 10)
|
參考:
https://cmake.org/cmake/help/latest/module/FetchContent.html#integrating-with-find-package
https://cmake.org/cmake/help/v3.31/module/GoogleTest.html#command:gtest_add_tests