[clang-tools-extra] 26e1553 - [clangd] CMake: express -Iclangd/ at top level and inherit

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 2 00:52:48 PDT 2021


Author: Sam McCall
Date: 2021-07-02T09:52:36+02:00
New Revision: 26e1553a107f52667be879e99739a4153f8799d8

URL: https://github.com/llvm/llvm-project/commit/26e1553a107f52667be879e99739a4153f8799d8
DIFF: https://github.com/llvm/llvm-project/commit/26e1553a107f52667be879e99739a4153f8799d8.diff

LOG: [clangd] CMake: express -Iclangd/ at top level and inherit

For files directly under clangd/, -Iclang-tools-extra/clangd (and the
equivalent for generated files) are not required, as CMake/the compiler puts
these directories on the include path by default.

However this means each subdirectory needs to
include_directories(.. ${CMAKE_CURRENT_BINARY_DIR}/..) etc, and this
proved annoying and error-prone to maintain and debug.

Since include_directories is inherited by subdirectories, we just
configure this explicitly at the top level instead.

Added: 
    

Modified: 
    clang-tools-extra/clangd/CMakeLists.txt
    clang-tools-extra/clangd/benchmarks/CMakeLists.txt
    clang-tools-extra/clangd/benchmarks/CompletionModel/CMakeLists.txt
    clang-tools-extra/clangd/fuzzer/CMakeLists.txt
    clang-tools-extra/clangd/index/dex/dexp/CMakeLists.txt
    clang-tools-extra/clangd/index/remote/CMakeLists.txt
    clang-tools-extra/clangd/indexer/CMakeLists.txt
    clang-tools-extra/clangd/support/CMakeLists.txt
    clang-tools-extra/clangd/tool/CMakeLists.txt
    clang-tools-extra/clangd/unittests/CMakeLists.txt
    clang-tools-extra/clangd/unittests/xpc/CMakeLists.txt
    clang-tools-extra/clangd/xpc/CMakeLists.txt
    clang-tools-extra/clangd/xpc/test-client/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/CMakeLists.txt b/clang-tools-extra/clangd/CMakeLists.txt
index b983b71cc90f4..3c2b097e89fd1 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -1,3 +1,7 @@
+# This is a no-op for building files in this dir, but is inherited by subdirs.
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+
 add_subdirectory(support)
 
 # Configure the Features.inc file.

diff  --git a/clang-tools-extra/clangd/benchmarks/CMakeLists.txt b/clang-tools-extra/clangd/benchmarks/CMakeLists.txt
index 7a17637b6c377..b1bd26f2e5599 100644
--- a/clang-tools-extra/clangd/benchmarks/CMakeLists.txt
+++ b/clang-tools-extra/clangd/benchmarks/CMakeLists.txt
@@ -1,6 +1,3 @@
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..
-  ${CMAKE_CURRENT_BINARY_DIR}/..)
-
 add_subdirectory(CompletionModel)
 
 add_benchmark(IndexBenchmark IndexBenchmark.cpp)

diff  --git a/clang-tools-extra/clangd/benchmarks/CompletionModel/CMakeLists.txt b/clang-tools-extra/clangd/benchmarks/CompletionModel/CMakeLists.txt
index 3998aa1225338..4c7cd779eb3e7 100644
--- a/clang-tools-extra/clangd/benchmarks/CompletionModel/CMakeLists.txt
+++ b/clang-tools-extra/clangd/benchmarks/CompletionModel/CMakeLists.txt
@@ -1,5 +1,3 @@
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../)
-
 add_benchmark(DecisionForestBenchmark DecisionForestBenchmark.cpp)
 
 target_link_libraries(DecisionForestBenchmark

diff  --git a/clang-tools-extra/clangd/fuzzer/CMakeLists.txt b/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
index 18cab4b41e1a0..5600a354decb3 100644
--- a/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
+++ b/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
@@ -1,6 +1,3 @@
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..
-  ${CMAKE_CURRENT_BINARY_DIR}/..)
-
 set(LLVM_LINK_COMPONENTS
   FuzzMutate
   Support

diff  --git a/clang-tools-extra/clangd/index/dex/dexp/CMakeLists.txt b/clang-tools-extra/clangd/index/dex/dexp/CMakeLists.txt
index 7b4b6e53a4ad0..4fe42cb8786f1 100644
--- a/clang-tools-extra/clangd/index/dex/dexp/CMakeLists.txt
+++ b/clang-tools-extra/clangd/index/dex/dexp/CMakeLists.txt
@@ -1,6 +1,3 @@
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../)
-include_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../)
-
 set(LLVM_LINK_COMPONENTS
   LineEditor
   Support

diff  --git a/clang-tools-extra/clangd/index/remote/CMakeLists.txt b/clang-tools-extra/clangd/index/remote/CMakeLists.txt
index 51db6a7a141ee..5bfc241945437 100644
--- a/clang-tools-extra/clangd/index/remote/CMakeLists.txt
+++ b/clang-tools-extra/clangd/index/remote/CMakeLists.txt
@@ -13,8 +13,6 @@ if (CLANGD_ENABLE_REMOTE)
     MonitoringServiceProto
     )
   include_directories(${CMAKE_CURRENT_BINARY_DIR})
-  include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../)
-  include_directories(${CMAKE_CURRENT_BINARY_DIR}/../../)
 
   # FIXME(kirillbobyrev): target_compile_definitions is not working with
   # add_clang_library for some reason. Is there any way to make this

diff  --git a/clang-tools-extra/clangd/indexer/CMakeLists.txt b/clang-tools-extra/clangd/indexer/CMakeLists.txt
index f6389654b3628..a9438008ea039 100644
--- a/clang-tools-extra/clangd/indexer/CMakeLists.txt
+++ b/clang-tools-extra/clangd/indexer/CMakeLists.txt
@@ -1,6 +1,3 @@
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../)
-include_directories(${CMAKE_CURRENT_BINARY_DIR}/../)
-
 set(LLVM_LINK_COMPONENTS
     Support
     )

diff  --git a/clang-tools-extra/clangd/support/CMakeLists.txt b/clang-tools-extra/clangd/support/CMakeLists.txt
index fc7d7a28117b1..681505586ca9d 100644
--- a/clang-tools-extra/clangd/support/CMakeLists.txt
+++ b/clang-tools-extra/clangd/support/CMakeLists.txt
@@ -15,7 +15,6 @@ if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB OR NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
   list(APPEND CLANGD_ATOMIC_LIB "atomic")
 endif()
 
-include_directories(..)
 add_clang_library(clangdSupport
   Cancellation.cpp
   Context.cpp

diff  --git a/clang-tools-extra/clangd/tool/CMakeLists.txt b/clang-tools-extra/clangd/tool/CMakeLists.txt
index da9d2060f7009..5a1556b813b59 100644
--- a/clang-tools-extra/clangd/tool/CMakeLists.txt
+++ b/clang-tools-extra/clangd/tool/CMakeLists.txt
@@ -1,6 +1,3 @@
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
-include_directories(${CMAKE_CURRENT_BINARY_DIR}/..)
-
 add_clang_tool(clangd
   ClangdMain.cpp
   Check.cpp

diff  --git a/clang-tools-extra/clangd/unittests/CMakeLists.txt b/clang-tools-extra/clangd/unittests/CMakeLists.txt
index 3a439b11e6322..2f5a754f882ae 100644
--- a/clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ b/clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -4,15 +4,6 @@ set(LLVM_LINK_COMPONENTS
   FrontendOpenMP
   )
 
-get_filename_component(CLANGD_SOURCE_DIR
-  ${CMAKE_CURRENT_SOURCE_DIR}/../../clangd REALPATH)
-get_filename_component(CLANGD_BINARY_DIR
-  ${CMAKE_CURRENT_BINARY_DIR}/../../clangd REALPATH)
-include_directories(
-  ${CLANGD_SOURCE_DIR}
-  ${CLANGD_BINARY_DIR}
-  )
-
 if(CLANG_BUILT_STANDALONE)
   # LLVMTestingSupport library is needed for clangd tests.
   if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support

diff  --git a/clang-tools-extra/clangd/unittests/xpc/CMakeLists.txt b/clang-tools-extra/clangd/unittests/xpc/CMakeLists.txt
index 372528d1e82d3..ac04c3f4aed66 100644
--- a/clang-tools-extra/clangd/unittests/xpc/CMakeLists.txt
+++ b/clang-tools-extra/clangd/unittests/xpc/CMakeLists.txt
@@ -2,15 +2,6 @@ set(LLVM_LINK_COMPONENTS
   support
   )
 
-get_filename_component(CLANGD_SOURCE_DIR
-  ${CMAKE_CURRENT_SOURCE_DIR}/../../clangd REALPATH)
-get_filename_component(CLANGD_BINARY_DIR
-  ${CMAKE_CURRENT_SOURCE_DIR}/../../clangd REALPATH)
-include_directories(
-  ${CLANGD_SOURCE_DIR}
-  ${CLANGD_BINARY_DIR}
-  )
-
 add_custom_target(ClangdXpcUnitTests)
 add_unittest(ClangdXpcUnitTests ClangdXpcTests
   ConversionTests.cpp

diff  --git a/clang-tools-extra/clangd/xpc/CMakeLists.txt b/clang-tools-extra/clangd/xpc/CMakeLists.txt
index d551f8b2b5b3c..5ccdf2f5d06a5 100644
--- a/clang-tools-extra/clangd/xpc/CMakeLists.txt
+++ b/clang-tools-extra/clangd/xpc/CMakeLists.txt
@@ -7,11 +7,6 @@ include(CreateClangdXPCFramework)
 add_subdirectory(framework)
 add_subdirectory(test-client)
 
-include_directories(
-  ${CMAKE_CURRENT_SOURCE_DIR}/../
-  ${CMAKE_CURRENT_BINARY_DIR}/../
-)
-
 set(LLVM_LINK_COMPONENTS
   Support
   )

diff  --git a/clang-tools-extra/clangd/xpc/test-client/CMakeLists.txt b/clang-tools-extra/clangd/xpc/test-client/CMakeLists.txt
index 1bf01c63d7224..94477e3bc57e6 100644
--- a/clang-tools-extra/clangd/xpc/test-client/CMakeLists.txt
+++ b/clang-tools-extra/clangd/xpc/test-client/CMakeLists.txt
@@ -1,7 +1,3 @@
-include_directories(
-  ${CMAKE_CURRENT_SOURCE_DIR}/../../
-)
-
 add_clang_tool(
   clangd-xpc-test-client
   ClangdXPCTestClient.cpp


        


More information about the cfe-commits mailing list