xref: /OK3568_Linux_fs/buildroot/package/taskd/0003-CMakeLists-use-pkg-config-uuid-detection.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1CMakeLists.txt: use pkg-config to detect uuid when possible
2
3In order to take into account the libraries used by libuuid when
4building statically, using pkg-config is recommended. This patch
5therefore improves the CMakeLists.txt to use pkg-config to detect
6libuuid when pkg-config is available.
7
8Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
9
10Index: b/CMakeLists.txt
11===================================================================
12--- a/CMakeLists.txt
13+++ b/CMakeLists.txt
14@@ -6,6 +6,7 @@
15
16 include (CheckFunctionExists)
17 include (CheckStructHasMember)
18+include (FindPkgConfig)
19
20 set (HAVE_CMAKE true)
21
22@@ -119,8 +120,16 @@
23   # Apple and FreeBSD include the uuid functions in their libc, rather than libuuid
24   check_function_exists (uuid_unparse_lower HAVE_UUID_UNPARSE_LOWER)
25 else (DARWIN OR FREEBSD)
26-  find_path    (UUID_INCLUDE_DIR   uuid/uuid.h)
27-  find_library (UUID_LIBRARY NAMES uuid)
28+  if(PKG_CONFIG_FOUND)
29+    pkg_check_modules(PC_UUID uuid)
30+    if(PC_UUID_FOUND)
31+      set (UUID_INCLUDE_DIR ${PC_UUID_INCLUDE_DIRS})
32+      set (UUID_LIBRARY ${PC_UUID_LIBRARIES})
33+    endif(PC_UUID_FOUND)
34+  else(PKG_CONFIG_FOUND)
35+    find_path    (UUID_INCLUDE_DIR   uuid/uuid.h)
36+    find_library (UUID_LIBRARY NAMES uuid)
37+  endif(PKG_CONFIG_FOUND)
38   if (UUID_INCLUDE_DIR AND UUID_LIBRARY)
39     set (TASKD_INCLUDE_DIRS ${TASKD_INCLUDE_DIRS} ${UUID_INCLUDE_DIR})
40     set (TASKD_LIBRARIES    ${TASKD_LIBRARIES}    ${UUID_LIBRARY})
41