0003-CMakeLists-use-pkg-config-uuid-detection.patch 1.4 KB

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