5 # Find Talloc include dirs and libraries.
10 # This module defines the following :ref:`Imported Targets <Imported Targets>`:
17 # This module defines the following variables:
21 # ``TALLOC_INCLUDE_DIRS``
23 # ``TALLOC_LIBRARIES``
27 # ``TALLOC_VERSION_MAJOR``
29 # ``TALLOC_VERSION_MINOR``
34 # Search results are saved persistently in CMake cache entries:
36 # ``TALLOC_INCLUDE_DIR``
40 include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
41 find_package(PkgConfig QUIET)
44 if(CMAKE_VERSION VERSION_GREATER 3.6)
45 pkg_check_modules(talloc QUIET IMPORTED_TARGET talloc)
47 pkg_check_modules(talloc QUIET talloc)
51 set(TALLOC_VERSION ${talloc_VERSION})
56 find_library(TALLOC_LIBRARY
57 NAMES talloc NAMES_PER_DIR
58 HINTS ${talloc_LIBRARY_DIRS}
60 mark_as_advanced(TALLOC_LIBRARY)
61 if(EXISTS "${TALLOC_LIBRARY}")
62 list(APPEND TALLOC_LIBRARIES ${TALLOC_LIBRARY})
65 find_path(TALLOC_INCLUDE_DIR
67 HINTS ${talloc_INCLUDE_DIRS}
69 mark_as_advanced(TALLOC_INCLUDE_DIR)
70 if(EXISTS "${TALLOC_INCLUDE_DIR}")
71 list(APPEND TALLOC_INCLUDE_DIRS ${TALLOC_INCLUDE_DIR})
74 if(NOT TALLOC_VERSION AND EXISTS "${TALLOC_INCLUDE_DIR}/talloc.h")
75 file(STRINGS ${TALLOC_INCLUDE_DIR}/talloc.h text REGEX "TALLOC_VERSION")
76 string(REGEX REPLACE ".*VERSION_MAJOR[^0-9]+([0-9]+).*" "\\1" TALLOC_VERSION_MAJOR ${text})
77 string(REGEX REPLACE ".*VERSION_MINOR[^0-9]+([0-9]+).*" "\\1" TALLOC_VERSION_MINOR ${text})
78 set(TALLOC_VERSION ${TALLOC_VERSION_MAJOR}.${TALLOC_VERSION_MINOR})
82 find_package_handle_standard_args(Talloc
92 if(TARGET PkgConfig::talloc)
93 add_library(Talloc::talloc ALIAS PkgConfig::talloc)
95 if(NOT TARGET Talloc::talloc AND EXISTS "${TALLOC_LIBRARY}")
96 add_library(Talloc::talloc UNKNOWN IMPORTED)
97 set_target_properties(Talloc::talloc PROPERTIES
98 INTERFACE_INCLUDE_DIRECTORIES "${TALLOC_INCLUDE_DIR}"
99 IMPORTED_LOCATION "${TALLOC_LIBRARY}"
100 IMPORTED_LINK_INTERFACE_LANGUAGES C