CMakeLists.txt 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. #------------------------------------------------------------------------------
  2. # Build the google test library
  3. # We compile Google Test ourselves instead of using pre-compiled libraries.
  4. # See the Google Test FAQ "Why is it not recommended to install a
  5. # pre-compiled copy of Google Test (for example, into /usr/local)?"
  6. # at http://code.google.com/p/googletest/wiki/FAQ for more details.
  7. add_library(gtest STATIC
  8. gmock-gtest-all.cc gmock/gmock.h gtest/gtest.h gtest/gtest-spi.h)
  9. target_compile_definitions(gtest PUBLIC GTEST_HAS_STD_WSTRING=1)
  10. target_include_directories(gtest SYSTEM PUBLIC .)
  11. target_compile_features(gtest PUBLIC cxx_std_11)
  12. find_package(Threads)
  13. if (Threads_FOUND)
  14. target_link_libraries(gtest ${CMAKE_THREAD_LIBS_INIT})
  15. else ()
  16. target_compile_definitions(gtest PUBLIC GTEST_HAS_PTHREAD=0)
  17. endif ()
  18. if (MSVC)
  19. # Disable MSVC warnings of _CRT_INSECURE_DEPRECATE functions.
  20. target_compile_definitions(gtest PRIVATE _CRT_SECURE_NO_WARNINGS)
  21. if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  22. # Disable MSVC warnings of POSIX functions.
  23. target_compile_options(gtest PUBLIC -Wno-deprecated-declarations)
  24. endif ()
  25. endif ()
  26. # Silence MSVC tr1 deprecation warning in gmock.
  27. target_compile_definitions(gtest
  28. PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1)