FindLibrist.cmake 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # Once done these will be defined:
  2. #
  3. # LIBRIST_FOUND LIBRIST_INCLUDE_DIRS LIBRIST_LIBRARIES
  4. #
  5. # For use in OBS:
  6. #
  7. # LIBRIST_INCLUDE_DIR
  8. find_package(PkgConfig QUIET)
  9. if(PKG_CONFIG_FOUND)
  10. pkg_check_modules(_LIBRIST QUIET librist)
  11. endif()
  12. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  13. set(_lib_suffix 64)
  14. else()
  15. set(_lib_suffix 32)
  16. endif()
  17. find_path(
  18. LIBRIST_INCLUDE_DIR
  19. NAMES librist.h librist/librist.h
  20. HINTS ENV LIBRIST_PATH ${LIBRIST_PATH} ${CMAKE_SOURCE_DIR}/${LIBRIST_PATH} ${_LIBRIST_INCLUDE_DIRS} ${DepsPath}
  21. PATHS /usr/include /usr/local/include /opt/local/include /sw/include
  22. PATH_SUFFIXES include)
  23. find_library(
  24. LIBRIST_LIB
  25. NAMES ${_LIBRIST_LIBRARIES} librist rist
  26. HINTS ENV LIBRIST_PATH ${LIBRIST_PATH} ${CMAKE_SOURCE_DIR}/${LIBRIST_PATH} ${_LIBRIST_LIBRARY_DIRS} ${DepsPath}
  27. PATHS /usr/lib /usr/local/lib /opt/local/lib /sw/lib
  28. PATH_SUFFIXES
  29. lib${_lib_suffix}
  30. lib
  31. libs${_lib_suffix}
  32. libs
  33. bin${_lib_suffix}
  34. bin
  35. ../lib${_lib_suffix}
  36. ../lib
  37. ../libs${_lib_suffix}
  38. ../libs
  39. ../bin${_lib_suffix}
  40. ../bin)
  41. include(FindPackageHandleStandardArgs)
  42. find_package_handle_standard_args(Librist DEFAULT_MSG LIBRIST_LIB LIBRIST_INCLUDE_DIR)
  43. mark_as_advanced(LIBRIST_INCLUDE_DIR LIBRIST_LIB)
  44. if(LIBRIST_FOUND)
  45. set(LIBRIST_INCLUDE_DIRS ${LIBRIST_INCLUDE_DIR})
  46. set(LIBRIST_LIBRARIES ${LIBRIST_LIB})
  47. if(NOT TARGET Librist::Librist)
  48. if(IS_ABSOLUTE "${LIBRIST_LIBRARIES}")
  49. add_library(Librist::Librist UNKNOWN IMPORTED)
  50. set_target_properties(Librist::Librist PROPERTIES IMPORTED_LOCATION "${LIBRIST_LIBRARIES}")
  51. else()
  52. add_library(Librist::Librist INTERFACE IMPORTED)
  53. set_target_properties(Librist::Librist PROPERTIES IMPORTED_LIBNAME "${LIBRIST_LIBRARIES}")
  54. endif()
  55. set_target_properties(Librist::Librist PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LIBRIST_INCLUDE_DIRS}")
  56. endif()
  57. else()
  58. message(STATUS "librist library not found")
  59. endif()