gtest的helloWorld
作者:互联网
参考官网:https://google.github.io/googletest/quickstart-cmake.html
【流程】
1)CMakeLists.txt
cmake_minimum_required(VERSION 3.14) project(my_project) # GoogleTest requires at least C++14 set(CMAKE_CXX_STANDARD 14) # For Windows: Prevent overriding the parent project's compiler/linker settings set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) enable_testing() find_package(GTest REQUIRED) add_executable( hello_test hello_test.cc ) target_link_libraries( hello_test GTest::gtest_main ) include(GoogleTest) gtest_discover_tests(hello_test)
增加find_package
2)编译运行
cmake -S . -B build
cmake --build build
cd build && ctest
标签:cmake,helloWorld,project,gtest,build,test,hello 来源: https://www.cnblogs.com/jiangshifu/p/16684522.html