Out-of-tree CMake dependencies

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Out-of-tree CMake dependencies

David Chisnall via cfe-dev
Hi all,

In include-what-you-use, we recently had this bug report:
https://github.com/include-what-you-use/include-what-you-use/pull/465

And it's symptomatic for a whole class of problems where we're
duplicating knowledge from the LLVM/Clang CMake systems to allow both
in-tree and out-of-tree IWYU development.

(in our terminology, in-tree == cloning the include-what-you-use repo
into a full LLVM and Clang checkout/clone under
llvm/tools/clang/tools/include-what-you-use and out-of-tree == cloning
include-what-you-use anywhere, and giving CMake information about
where to find LLVM/Clang headers and libraries)

Looking around my system, I see a lot of CMake modules in
/usr/lib/llvm-4.0 and /usr/share/llvm-4.0, but it's not clear to me
how to use them. Also, it would be nice to allow a "next-to-tree"
configuration instead of in-tree, where I can point IWYU at a trunk
checkout of LLVM and Clang and use its CMake modules.

Is there a correct way to accomplish this?

Thanks,
- Kim
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Out-of-tree CMake dependencies

David Chisnall via cfe-dev
This might help you get started (this is for out of tree pointing to my development build, but you could also point to the installed version if you have one).

# if you only have/need LLVM:
#  export LLVM_DIR=/Users/dhinton/projects/llvm_project/build/Debug/lib/cmake/llvm
# if you also have/need clang:
#  export CLANG_DIR=/Users/dhinton/projects/llvm_project/build/Debug/lib/cmake/clang

# While just setting LLVM_DIR will make find_package work, you need to
# add it to CMAKE_MODULE_PATH if you want to include AddLLVM, e.g., if
# you want to use add_llvm_loadable_module.
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "$ENV{LLVM_DIR};$ENV{Clang_DIR}")
#find_package(LLVM REQUIRED CONFIG)
find_package(Clang REQUIRED CONFIG)
include(AddLLVM)
add_definitions(${LLVM_DEFINITIONS})
include_directories(${LLVM_INCLUDE_DIRS})
include_directories(${CLANG_INCLUDE_DIRS})
link_directories(${LLVM_LIBRARY_DIRS})

message("LLVM_DEFINITIONS = ${LLVM_DEFINITIONS}")
message("LLVM_INCLUDE_DIRS = ${LLVM_INCLUDE_DIRS}")
message("LLVM_LIBRARY_DIRS = ${LLVM_LIBRARY_DIRS}")
message("CLANG_INCLUDE_DIRS = ${CLANG_INCLUDE_DIRS}")

On Wed, Oct 4, 2017 at 11:39 AM, Kim Gräsman via cfe-dev <[hidden email]> wrote:
Hi all,

In include-what-you-use, we recently had this bug report:
https://github.com/include-what-you-use/include-what-you-use/pull/465

And it's symptomatic for a whole class of problems where we're
duplicating knowledge from the LLVM/Clang CMake systems to allow both
in-tree and out-of-tree IWYU development.

(in our terminology, in-tree == cloning the include-what-you-use repo
into a full LLVM and Clang checkout/clone under
llvm/tools/clang/tools/include-what-you-use and out-of-tree == cloning
include-what-you-use anywhere, and giving CMake information about
where to find LLVM/Clang headers and libraries)

Looking around my system, I see a lot of CMake modules in
/usr/lib/llvm-4.0 and /usr/share/llvm-4.0, but it's not clear to me
how to use them. Also, it would be nice to allow a "next-to-tree"
configuration instead of in-tree, where I can point IWYU at a trunk
checkout of LLVM and Clang and use its CMake modules.

Is there a correct way to accomplish this?

Thanks,
- Kim
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Out-of-tree CMake dependencies

David Chisnall via cfe-dev
s/CLANG_DIR/Clang_DIR/



On Wed, Oct 4, 2017 at 12:31 PM, Don Hinton <[hidden email]> wrote:
This might help you get started (this is for out of tree pointing to my development build, but you could also point to the installed version if you have one).

# if you only have/need LLVM:
#  export LLVM_DIR=/Users/dhinton/projects/llvm_project/build/Debug/lib/cmake/llvm
# if you also have/need clang:
#  export CLANG_DIR=/Users/dhinton/projects/llvm_project/build/Debug/lib/cmake/clang

# While just setting LLVM_DIR will make find_package work, you need to
# add it to CMAKE_MODULE_PATH if you want to include AddLLVM, e.g., if
# you want to use add_llvm_loadable_module.
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "$ENV{LLVM_DIR};$ENV{Clang_DIR}")
#find_package(LLVM REQUIRED CONFIG)
find_package(Clang REQUIRED CONFIG)
include(AddLLVM)
add_definitions(${LLVM_DEFINITIONS})
include_directories(${LLVM_INCLUDE_DIRS})
include_directories(${CLANG_INCLUDE_DIRS})
link_directories(${LLVM_LIBRARY_DIRS})

message("LLVM_DEFINITIONS = ${LLVM_DEFINITIONS}")
message("LLVM_INCLUDE_DIRS = ${LLVM_INCLUDE_DIRS}")
message("LLVM_LIBRARY_DIRS = ${LLVM_LIBRARY_DIRS}")
message("CLANG_INCLUDE_DIRS = ${CLANG_INCLUDE_DIRS}")

On Wed, Oct 4, 2017 at 11:39 AM, Kim Gräsman via cfe-dev <[hidden email]> wrote:
Hi all,

In include-what-you-use, we recently had this bug report:
https://github.com/include-what-you-use/include-what-you-use/pull/465

And it's symptomatic for a whole class of problems where we're
duplicating knowledge from the LLVM/Clang CMake systems to allow both
in-tree and out-of-tree IWYU development.

(in our terminology, in-tree == cloning the include-what-you-use repo
into a full LLVM and Clang checkout/clone under
llvm/tools/clang/tools/include-what-you-use and out-of-tree == cloning
include-what-you-use anywhere, and giving CMake information about
where to find LLVM/Clang headers and libraries)

Looking around my system, I see a lot of CMake modules in
/usr/lib/llvm-4.0 and /usr/share/llvm-4.0, but it's not clear to me
how to use them. Also, it would be nice to allow a "next-to-tree"
configuration instead of in-tree, where I can point IWYU at a trunk
checkout of LLVM and Clang and use its CMake modules.

Is there a correct way to accomplish this?

Thanks,
- Kim
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Out-of-tree CMake dependencies

David Chisnall via cfe-dev
In reply to this post by David Chisnall via cfe-dev
Hi Don,

Thanks, that looks like it might work! I'll post back with results
when I have them.

- Kim

On Wed, Oct 4, 2017 at 9:31 PM, Don Hinton <[hidden email]> wrote:

> This might help you get started (this is for out of tree pointing to my
> development build, but you could also point to the installed version if you
> have one).
>
> # if you only have/need LLVM:
> #  export
> LLVM_DIR=/Users/dhinton/projects/llvm_project/build/Debug/lib/cmake/llvm
> # if you also have/need clang:
> #  export
> CLANG_DIR=/Users/dhinton/projects/llvm_project/build/Debug/lib/cmake/clang
>
> # While just setting LLVM_DIR will make find_package work, you need to
> # add it to CMAKE_MODULE_PATH if you want to include AddLLVM, e.g., if
> # you want to use add_llvm_loadable_module.
> set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "$ENV{LLVM_DIR};$ENV{Clang_DIR}")
> #find_package(LLVM REQUIRED CONFIG)
> find_package(Clang REQUIRED CONFIG)
> include(AddLLVM)
> add_definitions(${LLVM_DEFINITIONS})
> include_directories(${LLVM_INCLUDE_DIRS})
> include_directories(${CLANG_INCLUDE_DIRS})
> link_directories(${LLVM_LIBRARY_DIRS})
>
> message("LLVM_DEFINITIONS = ${LLVM_DEFINITIONS}")
> message("LLVM_INCLUDE_DIRS = ${LLVM_INCLUDE_DIRS}")
> message("LLVM_LIBRARY_DIRS = ${LLVM_LIBRARY_DIRS}")
> message("CLANG_INCLUDE_DIRS = ${CLANG_INCLUDE_DIRS}")
>
> On Wed, Oct 4, 2017 at 11:39 AM, Kim Gräsman via cfe-dev
> <[hidden email]> wrote:
>>
>> Hi all,
>>
>> In include-what-you-use, we recently had this bug report:
>> https://github.com/include-what-you-use/include-what-you-use/pull/465
>>
>> And it's symptomatic for a whole class of problems where we're
>> duplicating knowledge from the LLVM/Clang CMake systems to allow both
>> in-tree and out-of-tree IWYU development.
>>
>> (in our terminology, in-tree == cloning the include-what-you-use repo
>> into a full LLVM and Clang checkout/clone under
>> llvm/tools/clang/tools/include-what-you-use and out-of-tree == cloning
>> include-what-you-use anywhere, and giving CMake information about
>> where to find LLVM/Clang headers and libraries)
>>
>> Looking around my system, I see a lot of CMake modules in
>> /usr/lib/llvm-4.0 and /usr/share/llvm-4.0, but it's not clear to me
>> how to use them. Also, it would be nice to allow a "next-to-tree"
>> configuration instead of in-tree, where I can point IWYU at a trunk
>> checkout of LLVM and Clang and use its CMake modules.
>>
>> Is there a correct way to accomplish this?
>>
>> Thanks,
>> - Kim
>> _______________________________________________
>> cfe-dev mailing list
>> [hidden email]
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Out-of-tree CMake dependencies

David Chisnall via cfe-dev
You might also want to look at clang's CMakeLists.txt file.  I can be build either in or out of tree (llvm tree), and handles a lot of this via llvm-config.

hth...
don

On Wed, Oct 4, 2017 at 10:13 PM, Kim Gräsman <[hidden email]> wrote:
Hi Don,

Thanks, that looks like it might work! I'll post back with results
when I have them.

- Kim

On Wed, Oct 4, 2017 at 9:31 PM, Don Hinton <[hidden email]> wrote:
> This might help you get started (this is for out of tree pointing to my
> development build, but you could also point to the installed version if you
> have one).
>
> # if you only have/need LLVM:
> #  export
> LLVM_DIR=/Users/dhinton/projects/llvm_project/build/Debug/lib/cmake/llvm
> # if you also have/need clang:
> #  export
> CLANG_DIR=/Users/dhinton/projects/llvm_project/build/Debug/lib/cmake/clang
>
> # While just setting LLVM_DIR will make find_package work, you need to
> # add it to CMAKE_MODULE_PATH if you want to include AddLLVM, e.g., if
> # you want to use add_llvm_loadable_module.
> set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "$ENV{LLVM_DIR};$ENV{Clang_DIR}")
> #find_package(LLVM REQUIRED CONFIG)
> find_package(Clang REQUIRED CONFIG)
> include(AddLLVM)
> add_definitions(${LLVM_DEFINITIONS})
> include_directories(${LLVM_INCLUDE_DIRS})
> include_directories(${CLANG_INCLUDE_DIRS})
> link_directories(${LLVM_LIBRARY_DIRS})
>
> message("LLVM_DEFINITIONS = ${LLVM_DEFINITIONS}")
> message("LLVM_INCLUDE_DIRS = ${LLVM_INCLUDE_DIRS}")
> message("LLVM_LIBRARY_DIRS = ${LLVM_LIBRARY_DIRS}")
> message("CLANG_INCLUDE_DIRS = ${CLANG_INCLUDE_DIRS}")
>
> On Wed, Oct 4, 2017 at 11:39 AM, Kim Gräsman via cfe-dev
> <[hidden email]> wrote:
>>
>> Hi all,
>>
>> In include-what-you-use, we recently had this bug report:
>> https://github.com/include-what-you-use/include-what-you-use/pull/465
>>
>> And it's symptomatic for a whole class of problems where we're
>> duplicating knowledge from the LLVM/Clang CMake systems to allow both
>> in-tree and out-of-tree IWYU development.
>>
>> (in our terminology, in-tree == cloning the include-what-you-use repo
>> into a full LLVM and Clang checkout/clone under
>> llvm/tools/clang/tools/include-what-you-use and out-of-tree == cloning
>> include-what-you-use anywhere, and giving CMake information about
>> where to find LLVM/Clang headers and libraries)
>>
>> Looking around my system, I see a lot of CMake modules in
>> /usr/lib/llvm-4.0 and /usr/share/llvm-4.0, but it's not clear to me
>> how to use them. Also, it would be nice to allow a "next-to-tree"
>> configuration instead of in-tree, where I can point IWYU at a trunk
>> checkout of LLVM and Clang and use its CMake modules.
>>
>> Is there a correct way to accomplish this?
>>
>> Thanks,
>> - Kim
>> _______________________________________________
>> cfe-dev mailing list
>> [hidden email]
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Out-of-tree CMake dependencies

David Chisnall via cfe-dev
Hi all,

I now have a draft version that seems to be working:
https://github.com/kimgr/include-what-you-use/blob/re-cmake/CMakeLists.txt

I needed to add `include (HandleLLVMOptions)` to get CFLAGS/CXXFLAGS
in place, otherwise I was able to use your example almost verbatim.

Both the build and FreeBSD packaging seem to put the LLVM and Clang
CMake modules in $PREFIX/lib/cmake, but the apt packages for Ubuntu
seem to scatter them:

  $ find /usr -name "ClangConfig.cmake" -o -name "LLVMConfig.cmake" 2> /dev/null
  /usr/lib/llvm-4.0/lib/cmake/llvm/LLVMConfig.cmake
  /usr/share/llvm-4.0/cmake/ClangConfig.cmake

The corresponding layout on FreeBSD is:

  $ find /usr/local -name "ClangConfig.cmake" -o -name
"LLVMConfig.cmake" 2> /dev/null
  /usr/local/llvm40/lib/cmake/llvm/LLVMConfig.cmake
  /usr/local/llvm40/lib/cmake/clang/ClangConfig.cmake
  /usr/local/llvm39/lib/cmake/clang/ClangConfig.cmake
  /usr/local/llvm39/lib/cmake/llvm/LLVMConfig.cmake
  /usr/local/llvm-devel/lib/cmake/clang/ClangConfig.cmake
  /usr/local/llvm-devel/lib/cmake/llvm/LLVMConfig.cmake

This makes the UX for IWYU's CMake painful, as we have to specify both
CMake search paths:

    $ cmake -DIWYU_LLVM_CMAKE_DIR=/usr/lib/llvm-4.0/cmake
-DIWYU_CLANG_CMAKE_DIR=/usr/share/llvm-4.0/cmake

Could this be improved in the packaging, or is there a benefit to
keeping them separate? Am I missing some trick to make system packages
easier to pick up?

Thanks,
- Kim

On Thu, Oct 5, 2017 at 7:45 PM, Don Hinton <[hidden email]> wrote:

> You might also want to look at clang's CMakeLists.txt file.  I can be build
> either in or out of tree (llvm tree), and handles a lot of this via
> llvm-config.
>
> hth...
> don
>
> On Wed, Oct 4, 2017 at 10:13 PM, Kim Gräsman <[hidden email]> wrote:
>>
>> Hi Don,
>>
>> Thanks, that looks like it might work! I'll post back with results
>> when I have them.
>>
>> - Kim
>>
>> On Wed, Oct 4, 2017 at 9:31 PM, Don Hinton <[hidden email]> wrote:
>> > This might help you get started (this is for out of tree pointing to my
>> > development build, but you could also point to the installed version if
>> > you
>> > have one).
>> >
>> > # if you only have/need LLVM:
>> > #  export
>> > LLVM_DIR=/Users/dhinton/projects/llvm_project/build/Debug/lib/cmake/llvm
>> > # if you also have/need clang:
>> > #  export
>> >
>> > CLANG_DIR=/Users/dhinton/projects/llvm_project/build/Debug/lib/cmake/clang
>> >
>> > # While just setting LLVM_DIR will make find_package work, you need to
>> > # add it to CMAKE_MODULE_PATH if you want to include AddLLVM, e.g., if
>> > # you want to use add_llvm_loadable_module.
>> > set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
>> > "$ENV{LLVM_DIR};$ENV{Clang_DIR}")
>> > #find_package(LLVM REQUIRED CONFIG)
>> > find_package(Clang REQUIRED CONFIG)
>> > include(AddLLVM)
>> > add_definitions(${LLVM_DEFINITIONS})
>> > include_directories(${LLVM_INCLUDE_DIRS})
>> > include_directories(${CLANG_INCLUDE_DIRS})
>> > link_directories(${LLVM_LIBRARY_DIRS})
>> >
>> > message("LLVM_DEFINITIONS = ${LLVM_DEFINITIONS}")
>> > message("LLVM_INCLUDE_DIRS = ${LLVM_INCLUDE_DIRS}")
>> > message("LLVM_LIBRARY_DIRS = ${LLVM_LIBRARY_DIRS}")
>> > message("CLANG_INCLUDE_DIRS = ${CLANG_INCLUDE_DIRS}")
>> >
>> > On Wed, Oct 4, 2017 at 11:39 AM, Kim Gräsman via cfe-dev
>> > <[hidden email]> wrote:
>> >>
>> >> Hi all,
>> >>
>> >> In include-what-you-use, we recently had this bug report:
>> >> https://github.com/include-what-you-use/include-what-you-use/pull/465
>> >>
>> >> And it's symptomatic for a whole class of problems where we're
>> >> duplicating knowledge from the LLVM/Clang CMake systems to allow both
>> >> in-tree and out-of-tree IWYU development.
>> >>
>> >> (in our terminology, in-tree == cloning the include-what-you-use repo
>> >> into a full LLVM and Clang checkout/clone under
>> >> llvm/tools/clang/tools/include-what-you-use and out-of-tree == cloning
>> >> include-what-you-use anywhere, and giving CMake information about
>> >> where to find LLVM/Clang headers and libraries)
>> >>
>> >> Looking around my system, I see a lot of CMake modules in
>> >> /usr/lib/llvm-4.0 and /usr/share/llvm-4.0, but it's not clear to me
>> >> how to use them. Also, it would be nice to allow a "next-to-tree"
>> >> configuration instead of in-tree, where I can point IWYU at a trunk
>> >> checkout of LLVM and Clang and use its CMake modules.
>> >>
>> >> Is there a correct way to accomplish this?
>> >>
>> >> Thanks,
>> >> - Kim
>> >> _______________________________________________
>> >> cfe-dev mailing list
>> >> [hidden email]
>> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>> >
>> >
>
>
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Out-of-tree CMake dependencies

David Chisnall via cfe-dev
Ping.

Maybe a little too much detail below. TL;DR; why are Clang CMake
modules for installed separately from LLVM CMake modules in the Debian
packaging?

Thanks,
- Kim

On Sun, Oct 8, 2017 at 11:57 AM, Kim Gräsman <[hidden email]> wrote:

> Hi all,
>
> I now have a draft version that seems to be working:
> https://github.com/kimgr/include-what-you-use/blob/re-cmake/CMakeLists.txt
>
> I needed to add `include (HandleLLVMOptions)` to get CFLAGS/CXXFLAGS
> in place, otherwise I was able to use your example almost verbatim.
>
> Both the build and FreeBSD packaging seem to put the LLVM and Clang
> CMake modules in $PREFIX/lib/cmake, but the apt packages for Ubuntu
> seem to scatter them:
>
>   $ find /usr -name "ClangConfig.cmake" -o -name "LLVMConfig.cmake" 2> /dev/null
>   /usr/lib/llvm-4.0/lib/cmake/llvm/LLVMConfig.cmake
>   /usr/share/llvm-4.0/cmake/ClangConfig.cmake
>
> The corresponding layout on FreeBSD is:
>
>   $ find /usr/local -name "ClangConfig.cmake" -o -name
> "LLVMConfig.cmake" 2> /dev/null
>   /usr/local/llvm40/lib/cmake/llvm/LLVMConfig.cmake
>   /usr/local/llvm40/lib/cmake/clang/ClangConfig.cmake
>   /usr/local/llvm39/lib/cmake/clang/ClangConfig.cmake
>   /usr/local/llvm39/lib/cmake/llvm/LLVMConfig.cmake
>   /usr/local/llvm-devel/lib/cmake/clang/ClangConfig.cmake
>   /usr/local/llvm-devel/lib/cmake/llvm/LLVMConfig.cmake
>
> This makes the UX for IWYU's CMake painful, as we have to specify both
> CMake search paths:
>
>     $ cmake -DIWYU_LLVM_CMAKE_DIR=/usr/lib/llvm-4.0/cmake
> -DIWYU_CLANG_CMAKE_DIR=/usr/share/llvm-4.0/cmake
>
> Could this be improved in the packaging, or is there a benefit to
> keeping them separate? Am I missing some trick to make system packages
> easier to pick up?
>
> Thanks,
> - Kim
>
> On Thu, Oct 5, 2017 at 7:45 PM, Don Hinton <[hidden email]> wrote:
>> You might also want to look at clang's CMakeLists.txt file.  I can be build
>> either in or out of tree (llvm tree), and handles a lot of this via
>> llvm-config.
>>
>> hth...
>> don
>>
>> On Wed, Oct 4, 2017 at 10:13 PM, Kim Gräsman <[hidden email]> wrote:
>>>
>>> Hi Don,
>>>
>>> Thanks, that looks like it might work! I'll post back with results
>>> when I have them.
>>>
>>> - Kim
>>>
>>> On Wed, Oct 4, 2017 at 9:31 PM, Don Hinton <[hidden email]> wrote:
>>> > This might help you get started (this is for out of tree pointing to my
>>> > development build, but you could also point to the installed version if
>>> > you
>>> > have one).
>>> >
>>> > # if you only have/need LLVM:
>>> > #  export
>>> > LLVM_DIR=/Users/dhinton/projects/llvm_project/build/Debug/lib/cmake/llvm
>>> > # if you also have/need clang:
>>> > #  export
>>> >
>>> > CLANG_DIR=/Users/dhinton/projects/llvm_project/build/Debug/lib/cmake/clang
>>> >
>>> > # While just setting LLVM_DIR will make find_package work, you need to
>>> > # add it to CMAKE_MODULE_PATH if you want to include AddLLVM, e.g., if
>>> > # you want to use add_llvm_loadable_module.
>>> > set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
>>> > "$ENV{LLVM_DIR};$ENV{Clang_DIR}")
>>> > #find_package(LLVM REQUIRED CONFIG)
>>> > find_package(Clang REQUIRED CONFIG)
>>> > include(AddLLVM)
>>> > add_definitions(${LLVM_DEFINITIONS})
>>> > include_directories(${LLVM_INCLUDE_DIRS})
>>> > include_directories(${CLANG_INCLUDE_DIRS})
>>> > link_directories(${LLVM_LIBRARY_DIRS})
>>> >
>>> > message("LLVM_DEFINITIONS = ${LLVM_DEFINITIONS}")
>>> > message("LLVM_INCLUDE_DIRS = ${LLVM_INCLUDE_DIRS}")
>>> > message("LLVM_LIBRARY_DIRS = ${LLVM_LIBRARY_DIRS}")
>>> > message("CLANG_INCLUDE_DIRS = ${CLANG_INCLUDE_DIRS}")
>>> >
>>> > On Wed, Oct 4, 2017 at 11:39 AM, Kim Gräsman via cfe-dev
>>> > <[hidden email]> wrote:
>>> >>
>>> >> Hi all,
>>> >>
>>> >> In include-what-you-use, we recently had this bug report:
>>> >> https://github.com/include-what-you-use/include-what-you-use/pull/465
>>> >>
>>> >> And it's symptomatic for a whole class of problems where we're
>>> >> duplicating knowledge from the LLVM/Clang CMake systems to allow both
>>> >> in-tree and out-of-tree IWYU development.
>>> >>
>>> >> (in our terminology, in-tree == cloning the include-what-you-use repo
>>> >> into a full LLVM and Clang checkout/clone under
>>> >> llvm/tools/clang/tools/include-what-you-use and out-of-tree == cloning
>>> >> include-what-you-use anywhere, and giving CMake information about
>>> >> where to find LLVM/Clang headers and libraries)
>>> >>
>>> >> Looking around my system, I see a lot of CMake modules in
>>> >> /usr/lib/llvm-4.0 and /usr/share/llvm-4.0, but it's not clear to me
>>> >> how to use them. Also, it would be nice to allow a "next-to-tree"
>>> >> configuration instead of in-tree, where I can point IWYU at a trunk
>>> >> checkout of LLVM and Clang and use its CMake modules.
>>> >>
>>> >> Is there a correct way to accomplish this?
>>> >>
>>> >> Thanks,
>>> >> - Kim
>>> >> _______________________________________________
>>> >> cfe-dev mailing list
>>> >> [hidden email]
>>> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>> >
>>> >
>>
>>
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Out-of-tree CMake dependencies

David Chisnall via cfe-dev
+sylvestre -- you appear to be working on the Debian packaging of LLVM/Clang

Hey again,

I dug into the Debian packaging a bit more today, and it looks like
there have been changes to accommodate for the install location of
LLVMConfig.cmake, but not ClangConfig.cmake.

I think this might be a bug, but I don't feel confident enough/have a
clear enough problem report to file a package bug.

Could someone confirm/refute that it would make sense to install
LLVMConfig.cmake in /usr/lib/llvm-x.y/cmake/llvm and ClangConfig.cmake
in /usr/lib/llvm-x.y/cmake/clang?

Thanks,
- Kim

On Mon, Oct 30, 2017 at 9:16 PM, Kim Gräsman <[hidden email]> wrote:

> Ping.
>
> Maybe a little too much detail below. TL;DR; why are Clang CMake
> modules for installed separately from LLVM CMake modules in the Debian
> packaging?
>
> Thanks,
> - Kim
>
> On Sun, Oct 8, 2017 at 11:57 AM, Kim Gräsman <[hidden email]> wrote:
>> Hi all,
>>
>> I now have a draft version that seems to be working:
>> https://github.com/kimgr/include-what-you-use/blob/re-cmake/CMakeLists.txt
>>
>> I needed to add `include (HandleLLVMOptions)` to get CFLAGS/CXXFLAGS
>> in place, otherwise I was able to use your example almost verbatim.
>>
>> Both the build and FreeBSD packaging seem to put the LLVM and Clang
>> CMake modules in $PREFIX/lib/cmake, but the apt packages for Ubuntu
>> seem to scatter them:
>>
>>   $ find /usr -name "ClangConfig.cmake" -o -name "LLVMConfig.cmake" 2> /dev/null
>>   /usr/lib/llvm-4.0/lib/cmake/llvm/LLVMConfig.cmake
>>   /usr/share/llvm-4.0/cmake/ClangConfig.cmake
>>
>> The corresponding layout on FreeBSD is:
>>
>>   $ find /usr/local -name "ClangConfig.cmake" -o -name
>> "LLVMConfig.cmake" 2> /dev/null
>>   /usr/local/llvm40/lib/cmake/llvm/LLVMConfig.cmake
>>   /usr/local/llvm40/lib/cmake/clang/ClangConfig.cmake
>>   /usr/local/llvm39/lib/cmake/clang/ClangConfig.cmake
>>   /usr/local/llvm39/lib/cmake/llvm/LLVMConfig.cmake
>>   /usr/local/llvm-devel/lib/cmake/clang/ClangConfig.cmake
>>   /usr/local/llvm-devel/lib/cmake/llvm/LLVMConfig.cmake
>>
>> This makes the UX for IWYU's CMake painful, as we have to specify both
>> CMake search paths:
>>
>>     $ cmake -DIWYU_LLVM_CMAKE_DIR=/usr/lib/llvm-4.0/cmake
>> -DIWYU_CLANG_CMAKE_DIR=/usr/share/llvm-4.0/cmake
>>
>> Could this be improved in the packaging, or is there a benefit to
>> keeping them separate? Am I missing some trick to make system packages
>> easier to pick up?
>>
>> Thanks,
>> - Kim
>>
>> On Thu, Oct 5, 2017 at 7:45 PM, Don Hinton <[hidden email]> wrote:
>>> You might also want to look at clang's CMakeLists.txt file.  I can be build
>>> either in or out of tree (llvm tree), and handles a lot of this via
>>> llvm-config.
>>>
>>> hth...
>>> don
>>>
>>> On Wed, Oct 4, 2017 at 10:13 PM, Kim Gräsman <[hidden email]> wrote:
>>>>
>>>> Hi Don,
>>>>
>>>> Thanks, that looks like it might work! I'll post back with results
>>>> when I have them.
>>>>
>>>> - Kim
>>>>
>>>> On Wed, Oct 4, 2017 at 9:31 PM, Don Hinton <[hidden email]> wrote:
>>>> > This might help you get started (this is for out of tree pointing to my
>>>> > development build, but you could also point to the installed version if
>>>> > you
>>>> > have one).
>>>> >
>>>> > # if you only have/need LLVM:
>>>> > #  export
>>>> > LLVM_DIR=/Users/dhinton/projects/llvm_project/build/Debug/lib/cmake/llvm
>>>> > # if you also have/need clang:
>>>> > #  export
>>>> >
>>>> > CLANG_DIR=/Users/dhinton/projects/llvm_project/build/Debug/lib/cmake/clang
>>>> >
>>>> > # While just setting LLVM_DIR will make find_package work, you need to
>>>> > # add it to CMAKE_MODULE_PATH if you want to include AddLLVM, e.g., if
>>>> > # you want to use add_llvm_loadable_module.
>>>> > set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
>>>> > "$ENV{LLVM_DIR};$ENV{Clang_DIR}")
>>>> > #find_package(LLVM REQUIRED CONFIG)
>>>> > find_package(Clang REQUIRED CONFIG)
>>>> > include(AddLLVM)
>>>> > add_definitions(${LLVM_DEFINITIONS})
>>>> > include_directories(${LLVM_INCLUDE_DIRS})
>>>> > include_directories(${CLANG_INCLUDE_DIRS})
>>>> > link_directories(${LLVM_LIBRARY_DIRS})
>>>> >
>>>> > message("LLVM_DEFINITIONS = ${LLVM_DEFINITIONS}")
>>>> > message("LLVM_INCLUDE_DIRS = ${LLVM_INCLUDE_DIRS}")
>>>> > message("LLVM_LIBRARY_DIRS = ${LLVM_LIBRARY_DIRS}")
>>>> > message("CLANG_INCLUDE_DIRS = ${CLANG_INCLUDE_DIRS}")
>>>> >
>>>> > On Wed, Oct 4, 2017 at 11:39 AM, Kim Gräsman via cfe-dev
>>>> > <[hidden email]> wrote:
>>>> >>
>>>> >> Hi all,
>>>> >>
>>>> >> In include-what-you-use, we recently had this bug report:
>>>> >> https://github.com/include-what-you-use/include-what-you-use/pull/465
>>>> >>
>>>> >> And it's symptomatic for a whole class of problems where we're
>>>> >> duplicating knowledge from the LLVM/Clang CMake systems to allow both
>>>> >> in-tree and out-of-tree IWYU development.
>>>> >>
>>>> >> (in our terminology, in-tree == cloning the include-what-you-use repo
>>>> >> into a full LLVM and Clang checkout/clone under
>>>> >> llvm/tools/clang/tools/include-what-you-use and out-of-tree == cloning
>>>> >> include-what-you-use anywhere, and giving CMake information about
>>>> >> where to find LLVM/Clang headers and libraries)
>>>> >>
>>>> >> Looking around my system, I see a lot of CMake modules in
>>>> >> /usr/lib/llvm-4.0 and /usr/share/llvm-4.0, but it's not clear to me
>>>> >> how to use them. Also, it would be nice to allow a "next-to-tree"
>>>> >> configuration instead of in-tree, where I can point IWYU at a trunk
>>>> >> checkout of LLVM and Clang and use its CMake modules.
>>>> >>
>>>> >> Is there a correct way to accomplish this?
>>>> >>
>>>> >> Thanks,
>>>> >> - Kim
>>>> >> _______________________________________________
>>>> >> cfe-dev mailing list
>>>> >> [hidden email]
>>>> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>>> >
>>>> >
>>>
>>>
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev