[waffle] [PATCH (maint-1.4)] cmake: Fix building with CMake 2.8.11

Jordan Justen jljusten at gmail.com
Fri Dec 5 20:18:24 PST 2014


On 2014-12-05 16:32:36, Chad Versace wrote:
> Regressed by commit 92116dae.
> 
> Waffle's CMakeLists declares that 2.8.11 is required, but commit
> 92116dae begin using a 2.8.12 feature: the PRIVATE keyword to
> target_link_libraries().  We should not bump Waffle's CMake requirement
> to 2.8.12, though, because RHEL-7 and Chrome OS still have only 2.8.11.
> 
> This patch fixes Waffle to use the PRIVATE keyword only if cmake >= 2.8.12.
> Otherwise, it falls back to the LINK_INTERFACE_LIBRARIES hack removed by
> 92116dae.
> 
> Reported-by: Matej Cepl <mcepl at cepl.eu>
> Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
> ---
> 
> 
> I tested this patch on Chrome OS (which has cmake-2.8.11) and Fedora 20 (with
> cmake-2.8.12). I don't have a Debian system to test on.
> 
>  src/waffle/CMakeLists.txt | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/src/waffle/CMakeLists.txt b/src/waffle/CMakeLists.txt
> index 0e42192..ab10498 100644
> --- a/src/waffle/CMakeLists.txt
> +++ b/src/waffle/CMakeLists.txt
> @@ -180,7 +180,27 @@ include_directories(
>      )
>  
>  add_library(${waffle_libname} SHARED ${waffle_sources})
> -target_link_libraries(${waffle_libname} PRIVATE ${waffle_libdeps})
> +
> +# Debian's packaging system emits warnings if wflinfo directly links to any
> +# library that it doesn't directly use. Silence the warnings by annotating
> +# libwaffle's library dependencies as private, which prevents wflinfo from
> +# linking to them.

Maybe just focus on the general linking issue for this comment rather
than mentioning silencing the debian warning? (I think the usefulness
extends beyond silencing the debian warning. :)

I tested this patch on debian with cmake 3.0.2.

With or without the comment above tweaked,
Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>

> +if(CMAKE_VERSION VERSION_LESS "2.8.12")
> +    # On older CMake, we must rely on hacking the LINK_INTERFACE_LIBRARIES
> +    # property.
> +    if(NOT waffle_on_mac)
> +        set_target_properties(${waffle_libname}
> +            PROPERTIES
> +            LINK_INTERFACE_LIBRARIES ""
> +            )
> +    endif()
> +else()
> +    # CMake 2.8.12 introduced the PRIVATE keyword to target_link_libraries().
> +    # All libraries listed after PRIVATE get annotated as such.
> +    list(INSERT waffle_libdeps 0 PRIVATE)
> +endif()
> +
> +target_link_libraries(${waffle_libname} ${waffle_libdeps})
>  
>  set_target_properties(${waffle_libname}
>      PROPERTIES
> -- 
> 2.1.2.1.g5433a3e
> 
> _______________________________________________
> waffle mailing list
> waffle at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/waffle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: signature
URL: <http://lists.freedesktop.org/archives/waffle/attachments/20141205/ff7b0511/attachment.sig>


More information about the waffle mailing list