[cfe-dev] Dependencies between tools

Pavel Labath via cfe-dev cfe-dev at lists.llvm.org
Wed May 16 01:17:24 PDT 2018


I guess the typical include path would be something like
"clang-tidy/whatever.h". For that to work, all you would need to do is to
add `include_directories(${CMAKE_CURRENT_SOURCE_DIR})` to the
CMakeLists.txt at the clang-tools-extra root.

Having the repository root in your include path is a bit weird, but there
isn't anything better we can do, given the current repo layout. For example
the other llvm projects (and other projects in general) put headers into a
special "include" folder (so e.g., llvm's Support/Path.h lives in
<repo_root>/include/llvm/Support/Path.h) and the include search path points
there. If you're willing to endure some (fairly invasive) layout changes
then we could rearrange the clang-tools-extra repo to follow that layout.
Otherwise, setting the include path to the repo root should be good enough.

On Mon, 14 May 2018 at 17:47, Alexander Kornienko via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> I also don't know much about CMake, but it looks like add_clang_library
is enough for libraries in the Clang tree. Apparently, it does something
specific to the clang tree layout (see `macro(add_clang_library ...` in
cmake/modules/AddClang.cmake, it refers to
${CLANG_SOURCE_DIR}/include/clang/${lib_path}/*.h). Maybe a similar macro
should be added for tools/extra to allow libraries to be exported in a
similar way.

> On Mon, May 14, 2018 at 6:34 PM Chris Gray <chrismgray at google.com> wrote:

>> What path should be used in the #include statement?  I'm no CMake
expert, but I interpreted add_clang_library only to affect the linking
behavior, not what headers are visible.

>> On Mon, May 14, 2018 at 9:31 AM Alexander Kornienko <alexfh at google.com>
wrote:

>>> On Mon, Apr 23, 2018 at 11:10 AM Ilya Biryukov <ibiryukov at google.com>
wrote:

>>>> You're right, all of clang-extra-tools are not structured as
libraries. I guess the most principled approach would to follow LLVM's
convention and move public headers into include/, everything else to lib/,
etc.

>>>> +Alexander Kornienko, have you considered extracting a public library
interface for clang-tidy before? Any ideas on how to do it properly?


>>> Clang-tidy has been used as a library since its appearance. But this
was done outside the official source tree. If there's interest in using it
from clangd, but something is missing in the appropriate CMake configs, we
should fix them. However, it looks like
tools/extra/clang-tidy/CMakeLists.txt already defines
`add_clang_library(clangTidy ...`, which should be enough?

> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



More information about the cfe-dev mailing list