summaryrefslogtreecommitdiffstats
path: root/src/fmt/test/gtest/CMakeLists.txt
blob: ed0e59d5fc57c46f69dba2b8969cb7bdaa71d06f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#------------------------------------------------------------------------------
# Build the google test library

# We compile Google Test ourselves instead of using pre-compiled libraries.
# See the Google Test FAQ "Why is it not recommended to install a
# pre-compiled copy of Google Test (for example, into /usr/local)?"
# at http://code.google.com/p/googletest/wiki/FAQ for more details.
add_library(gtest STATIC
  gmock-gtest-all.cc gmock/gmock.h gtest/gtest.h gtest/gtest-spi.h)
target_compile_definitions(gtest PUBLIC GTEST_HAS_STD_WSTRING=1)
target_include_directories(gtest SYSTEM PUBLIC .)

find_package(Threads)
if (Threads_FOUND)
  target_link_libraries(gtest ${CMAKE_THREAD_LIBS_INIT})
else ()
  target_compile_definitions(gtest PUBLIC GTEST_HAS_PTHREAD=0)
endif ()

# Workaround GTest bug https://github.com/google/googletest/issues/705.
fmt_check_cxx_compiler_flag(
  -fno-delete-null-pointer-checks HAVE_FNO_DELETE_NULL_POINTER_CHECKS)
if (HAVE_FNO_DELETE_NULL_POINTER_CHECKS)
  target_compile_options(gtest PUBLIC -fno-delete-null-pointer-checks)
endif ()

if (MSVC)
  # Disable MSVC warnings of _CRT_INSECURE_DEPRECATE functions.
  target_compile_definitions(gtest PRIVATE _CRT_SECURE_NO_WARNINGS)
  if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
    # Disable MSVC warnings of POSIX functions.
    target_compile_options(gtest PUBLIC -Wno-deprecated-declarations)
  endif ()
endif ()

# Silence MSVC tr1 deprecation warning in gmock.
target_compile_definitions(gtest
  PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1)