[cmake] Make gtest include directories a part of the library interface
This applies the same fix that D84748 did for macro definitions. Appropriate include path is now automatically set for all libraries which link against gtest targets, which avoids the need to set include_directories in various parts of the project. Differential Revision: https://reviews.llvm.org/D86616
This commit is contained in:
parent
266825620c
commit
9cb222e749
|
@ -135,13 +135,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
|||
if (FLANG_INCLUDE_TESTS)
|
||||
set(UNITTEST_DIR ${LLVM_BUILD_MAIN_SRC_DIR}/utils/unittest)
|
||||
if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h)
|
||||
if (TARGET gtest)
|
||||
# LLVM Doesn't export gtest's include directorys, so do that here
|
||||
set_target_properties(gtest
|
||||
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${UNITTEST_DIR}/googletest/include;${UNITTEST_DIR}/googlemock/include"
|
||||
)
|
||||
else()
|
||||
if (NOT TARGET gtest)
|
||||
add_library(gtest
|
||||
${UNITTEST_DIR}/googletest/src/gtest-all.cc
|
||||
${UNITTEST_DIR}/googlemock/src/gmock-all.cc
|
||||
|
|
|
@ -53,11 +53,6 @@ function(add_libc_benchmark_unittest target_name)
|
|||
EXCLUDE_FROM_ALL
|
||||
${LIBC_BENCHMARKS_UNITTEST_SRCS}
|
||||
)
|
||||
target_include_directories(${target_name}
|
||||
PRIVATE
|
||||
${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include
|
||||
${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock/include
|
||||
)
|
||||
target_link_libraries(${target_name}
|
||||
PRIVATE
|
||||
gtest_main
|
||||
|
|
|
@ -2,7 +2,3 @@ set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL ON)
|
|||
add_lldb_library(lldbSymbolHelpers
|
||||
YAMLModuleTester.cpp
|
||||
)
|
||||
|
||||
target_include_directories(lldbSymbolHelpers PUBLIC
|
||||
${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include
|
||||
${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock/include)
|
||||
|
|
|
@ -1401,9 +1401,6 @@ function(add_unittest test_suite test_name)
|
|||
set(EXCLUDE_FROM_ALL ON)
|
||||
endif()
|
||||
|
||||
include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
|
||||
include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock/include)
|
||||
|
||||
if (SUPPORTS_VARIADIC_MACROS_FLAG)
|
||||
list(APPEND LLVM_COMPILE_FLAGS "-Wno-variadic-macros")
|
||||
endif ()
|
||||
|
|
|
@ -12,6 +12,4 @@ add_llvm_library(LLVMTestingSupport
|
|||
Support
|
||||
)
|
||||
|
||||
include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
|
||||
include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock/include)
|
||||
target_link_libraries(LLVMTestingSupport PRIVATE gtest)
|
||||
|
|
|
@ -11,14 +11,6 @@
|
|||
#
|
||||
# Project-wide settings
|
||||
|
||||
# Where gtest's .h files can be found.
|
||||
include_directories(
|
||||
googletest/include
|
||||
googletest
|
||||
googlemock/include
|
||||
googlemock
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
add_definitions(-DGTEST_OS_WINDOWS=1)
|
||||
endif()
|
||||
|
@ -76,6 +68,11 @@ if (NOT LLVM_ENABLE_THREADS)
|
|||
target_compile_definitions(gtest PUBLIC GTEST_HAS_PTHREAD=0)
|
||||
endif ()
|
||||
|
||||
target_include_directories(gtest
|
||||
PUBLIC googletest/include googlemock/include
|
||||
PRIVATE googletest googlemock
|
||||
)
|
||||
|
||||
add_subdirectory(UnitTestMain)
|
||||
|
||||
# When LLVM_LINK_LLVM_DYLIB is enabled, libLLVM.so is added to the interface
|
||||
|
|
|
@ -30,12 +30,6 @@ if (NOT DEFINED LLVM_MAIN_SRC_DIR)
|
|||
if (NOT TARGET gtest)
|
||||
add_subdirectory(${UNITTEST_DIR} utils/unittest)
|
||||
endif()
|
||||
|
||||
# LLVM Doesn't export gtest's include directorys, so do that here
|
||||
set_target_properties(gtest
|
||||
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${UNITTEST_DIR}/googletest/include;${UNITTEST_DIR}/googlemock/include"
|
||||
)
|
||||
set(POLLY_GTEST_AVAIL 1)
|
||||
endif()
|
||||
|
||||
|
|
Loading…
Reference in New Issue