2
0

googletest.cmake 824 B

1234567891011121314151617181920212223242526272829303132
  1. # the following code to fetch googletest
  2. # is inspired by and adapted after https://crascit.com/2015/07/25/cmake-gtest/
  3. # download and unpack googletest at configure time
  4. macro(fetch_googletest _download_module_path _download_root)
  5. set(GOOGLETEST_DOWNLOAD_ROOT ${_download_root})
  6. configure_file(
  7. ${_download_module_path}/googletest-download.cmake
  8. ${_download_root}/CMakeLists.txt
  9. @ONLY
  10. )
  11. unset(GOOGLETEST_DOWNLOAD_ROOT)
  12. execute_process(
  13. COMMAND
  14. "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
  15. WORKING_DIRECTORY
  16. ${_download_root}
  17. )
  18. execute_process(
  19. COMMAND
  20. "${CMAKE_COMMAND}" --build .
  21. WORKING_DIRECTORY
  22. ${_download_root}
  23. )
  24. # adds the targers: gtest, gtest_main, gmock, gmock_main
  25. add_subdirectory(
  26. ${_download_root}/googletest-src
  27. ${_download_root}/googletest-build
  28. )
  29. endmacro()