[PATCH 1/1] build/cmake: Fix CMP0023 warning with libffi

Dan Liew dan at su-root.co.uk
Wed Sep 3 14:22:20 PDT 2014


Thanks for taking a look. Sorry if the following questions sound dumb...

> Unless LLVMInterpreter's header files make reference to libffi
> symbols such that application code including them might get
> direct references, then PRIVATE is the correct keyword.  You
> are telling CMake that the library has an implementation-only
> dependency on the ffi library.

I'm a little confused as to why the PUBLIC, PRIVATE and INTERFACE
exist at all. Even if the library has an implementation-only
dependency any user of that library still needs to link against that
dependency, so there isn't anything "PRIVATE" about it.

I tried using PUBLIC, INTERFACE and PRIVATE and the libffi library is
in the list of libraries for the INTERFACE_LINK_LIBRARIES property of
LLVMInterpreter exported target in
``share/llvm/cmake/LLVMExports.cmake`` in all three cases. So it seems
these keywords have no affect on the exported targets despite the
documentation seeming to suggest otherwise (I assume "link interface"
means the INTERFACE_LINK_LIBRARIES property).

```
Libraries and targets following PUBLIC are  linked  to,  and  are
       made  part  of the link interface.  Libraries and targets
following PRIVATE are linked to, but are not made part of the link
interface.  Libraries following INTERFACE are appended to the link
inter‐
       face and are not used for linking <target>.
```

> In the case that LLVMInterpreter is a static library CMake will
> still take care of linking dependents transitively to ffi.  It
> puts in INTERFACE_LINK_LIBRARIES a $<LINK_ONLY:ffi> generator
> expression that tells dependents of LLVMInterpreter that they
> need to link to the library but need no usage requirements
> from it.
>

Thanks for that information. I'm not entirely sure what "usage
requirements" are but [1] seems to suggest they are the INTERFACE_*
(e.g.  INTERFACE_COMPILE_DEFINITIONS) target properties set by
``target_include_directories(), target_compile_definitions() and
target_compile_options()``. INTERFACE_LINK_LIBRARIES doesn't seem to a
usage requirement. Is that right?

Reading a little further on the example in [2] seems to suggest that
actually the PUBLIC, INTERFACE and PRIVATE keywords for
target_link_libraries() actually controls how these "usage
requirements" are propagated and actually has nothing to do with
setting the INTERFACE_LINK_LIBRARIES property at all.

[1] http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html#build-specification-and-usage-requirements
[2] http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html#transitive-usage-requirements


Thanks,
Dan.




More information about the llvm-commits mailing list