1 CMakeLists.txt: use pkg-config to detect uuid when possible
3 In order to take into account the libraries used by libuuid when
4 building statically, using pkg-config is recommended. This patch
5 therefore improves the CMakeLists.txt to use pkg-config to detect
6 libuuid when pkg-config is available.
8 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
10 Index: b/CMakeLists.txt
11 ===================================================================
16 include (CheckFunctionExists)
17 include (CheckStructHasMember)
18 +include (FindPkgConfig)
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)
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})