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