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

Chad Versace chad.versace at linux.intel.com
Fri Dec 5 16:32:36 PST 2014


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.
+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



More information about the waffle mailing list