forked from OSchip/llvm-project
[cmake] Make gtest macro definitions a part the library interface
These definitions are needed by any file which uses gtest. Previously we were adding them in the add_unittest function, but over time we've accumulated libraries (which don't go through add_unittest) building on gtest and this has resulted in proliferation of the definitions. Making this a part of the library interface enables them to be managed centrally. This follows a patch for -Wno-suggest-override (D84554) which took a similar approach. Differential Revision: https://reviews.llvm.org/D84748
This commit is contained in:
parent
d7d172b4aa
commit
bb91c9fe7b
|
@ -3,13 +3,6 @@ add_lldb_library(lldbSymbolHelpers
|
|||
YAMLModuleTester.cpp
|
||||
)
|
||||
|
||||
# Our current version of gtest does not properly recognize C++11 support
|
||||
# with MSVC, so it falls back to tr1 / experimental classes. Since LLVM
|
||||
# itself requires C++11, we can safely force it on unconditionally so that
|
||||
# we don't have to fight with the buggy gtest check.
|
||||
target_compile_definitions(lldbSymbolHelpers PUBLIC
|
||||
-DGTEST_LANG_CXX11=1
|
||||
-DGTEST_HAS_TR1_TUPLE=0)
|
||||
target_include_directories(lldbSymbolHelpers PUBLIC
|
||||
${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include
|
||||
${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock/include)
|
||||
|
|
|
@ -1400,15 +1400,8 @@ function(add_unittest test_suite test_name)
|
|||
set(EXCLUDE_FROM_ALL ON)
|
||||
endif()
|
||||
|
||||
# Our current version of gtest uses tr1/tuple which is deprecated on MSVC.
|
||||
# Since LLVM itself requires C++14, we can safely force it off.
|
||||
add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
|
||||
|
||||
include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
|
||||
include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock/include)
|
||||
if (NOT LLVM_ENABLE_THREADS)
|
||||
list(APPEND LLVM_COMPILE_DEFINITIONS GTEST_HAS_PTHREAD=0)
|
||||
endif ()
|
||||
|
||||
if (SUPPORTS_VARIADIC_MACROS_FLAG)
|
||||
list(APPEND LLVM_COMPILE_FLAGS "-Wno-variadic-macros")
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
add_definitions(-DGTEST_LANG_CXX11=1)
|
||||
add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
|
||||
|
||||
add_llvm_library(LLVMTestingSupport
|
||||
Annotations.cpp
|
||||
Error.cpp
|
||||
|
|
|
@ -19,9 +19,6 @@ include_directories(
|
|||
googlemock
|
||||
)
|
||||
|
||||
# Gtest 1.8.0 uses tr1/tuple which is deprecated on MSVC, so we force it off.
|
||||
add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
|
||||
|
||||
if(WIN32)
|
||||
add_definitions(-DGTEST_OS_WINDOWS=1)
|
||||
endif()
|
||||
|
@ -45,10 +42,6 @@ endif()
|
|||
set(LLVM_REQUIRES_RTTI 1)
|
||||
add_definitions( -DGTEST_HAS_RTTI=0 )
|
||||
|
||||
if (NOT LLVM_ENABLE_THREADS)
|
||||
add_definitions( -DGTEST_HAS_PTHREAD=0 )
|
||||
endif()
|
||||
|
||||
find_library(LLVM_PTHREAD_LIBRARY_PATH pthread)
|
||||
if (LLVM_PTHREAD_LIBRARY_PATH)
|
||||
list(APPEND LIBS pthread)
|
||||
|
@ -76,6 +69,13 @@ if(CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
|
|||
set_target_properties(gtest PROPERTIES INTERFACE_COMPILE_OPTIONS "-Wno-suggest-override")
|
||||
endif()
|
||||
|
||||
# Gtest 1.8.0 uses tr1/tuple which is deprecated on MSVC, so we force it off.
|
||||
target_compile_definitions(gtest PUBLIC GTEST_HAS_TR1_TUPLE=0)
|
||||
|
||||
if (NOT LLVM_ENABLE_THREADS)
|
||||
target_compile_definitions(gtest PUBLIC GTEST_HAS_PTHREAD=0)
|
||||
endif ()
|
||||
|
||||
add_subdirectory(UnitTestMain)
|
||||
|
||||
# When LLVM_LINK_LLVM_DYLIB is enabled, libLLVM.so is added to the interface
|
||||
|
|
Loading…
Reference in New Issue