1.4 KiB
1.4 KiB
GoogleTest: Download method
You can use the downloader in my CMake helper repository, using CMake's include
command.
This is a downloader for GoogleTest, based on the excellent DownloadProject tool. Downloading a copy for each project is the recommended way to use GoogleTest (so much so, in fact, that they have disabled the automatic CMake install target), so this respects that design decision. This method downloads the project at configure time, so that IDE's correctly find the libraries. Using it is simple:
cmake_minimum_required(VERSION 3.4)
project(MyProject CXX)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
enable_testing() # Must be in main file
include(AddGoogleTest) # Could be in /tests/CMakeLists.txt
add_executable(SimpleTest SimpleTest.cu)
add_gtest(SimpleTest)
Note:
add_gtest
is just a macro that addsgtest
,gmock
, andgtest_main
, and then runsadd_test
to create a test with the same name:target_link_libraries(SimpleTest gtest gmock gtest_main) add_test(SimpleTest SimpleTest)