From e258c2d84bcbd7238b2066ab97d3128841f2180f Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Wed, 12 Aug 2020 12:02:37 +0200 Subject: [PATCH] [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 --- cmake/modules/AddLLVM.cmake | 3 --- lib/Testing/Support/CMakeLists.txt | 2 -- utils/unittest/CMakeLists.txt | 13 +++++-------- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake index 1689d36171c..a40cf17426f 100644 --- a/cmake/modules/AddLLVM.cmake +++ b/cmake/modules/AddLLVM.cmake @@ -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 () diff --git a/lib/Testing/Support/CMakeLists.txt b/lib/Testing/Support/CMakeLists.txt index 4f5345c1dc5..ed2fd8ae43b 100644 --- a/lib/Testing/Support/CMakeLists.txt +++ b/lib/Testing/Support/CMakeLists.txt @@ -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) diff --git a/utils/unittest/CMakeLists.txt b/utils/unittest/CMakeLists.txt index 14c780342b6..43c8fafdfc4 100644 --- a/utils/unittest/CMakeLists.txt +++ b/utils/unittest/CMakeLists.txt @@ -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