[cfe-dev] LibTooling CMake Error

Philip Craig philipjcraig at gmail.com
Fri Oct 19 06:17:01 PDT 2012


On Fri, Oct 19, 2012 at 10:22 PM, Mohammad Adil <madil90 at gmail.com> wrote:
> I've checked out the extra tools repository at the correct place and I have
> built clang again, with the CLANG_BUILD_EXAMPLES variable set to true in
> cmake. I am still getting the same error. What can possibly be wrong? Can
> you please provide all the steps required to make this command work.

Did you place your example code in the extra tools repository as well?
There isn't any documentation for this, but it is straight forward to
copy how the existing tools in the repository are built.

>      The two cmake files you mentioned are both related to libclang. I am
> using Libtooling. How do I adapt them to build the FrontEndAction example
> given in the docs.

Tooling is part of libclang. I've pushed a version of the
FrontEndAction example that compiles for me to
https://github.com/philipc/find-class-decls

> On Fri, Oct 19, 2012 at 4:12 PM, Philip Craig <philipjcraig at gmail.com>
> wrote:
>>
>> On Fri, Oct 19, 2012 at 8:52 PM, madil90 <madil90 at gmail.com> wrote:
>> > Hi,
>> >    I am trying to setup LibTooling for clang. I have gone through the
>> > procedure given at </a>
>> > <http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html> . I can
>> > succesfully run clang-check for any source file. I am now trying to
>> > compile
>> > the example at  </a> <http://clang.llvm.org/docs/RAVFrontendAction.html>
>> > .
>> > When using cmake, I get the following error:
>> >
>> > Unknown CMake command : add_clang_executable
>> >
>> >   When using cmake to build clang, I used
>> > -DEXPORT_CMAKE_COMPILE_COMMANDS=ON
>> > variable as suggested. Then why isn't this command working?
>>
>> add_clang_executable is defined in the clang cmake files, so to use it
>> you need to build the example as part of clang. If you want to follow
>> this route, then a convenient place in the tree to put it is in the
>> extra tools repository. Have a look at
>> http://clang.llvm.org/docs/ClangTools.html
>>
>> Alternatively, to build standalone, you can try copying the cmake
>> configuration from
>> https://github.com/philipc/clang-ast/blob/master/CMakeLists.standalone
>> and
>> https://github.com/philipc/clang-ast/blob/master/cmake/modules/FindLibClang.cmake
>
>
>
>
> --
> Mohammad Adil
> LUMS SSE
>



More information about the cfe-dev mailing list