File: FindBiblesync.cmake

package info (click to toggle)
xiphos 4.2.1%2Bdfsg1-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 19,184 kB
  • sloc: ansic: 28,127; cpp: 13,020; python: 1,042; xml: 163; sh: 86; makefile: 29
file content (77 lines) | stat: -rwxr-xr-x 2,020 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# FindBiblesync.cmake
#
# Finds the Biblesync library
#
# This will define the following variables
#
#    BIBLESYNC_FOUND
#    BIBLESYNC_INCLUDE_DIRS
#    BIBLESYNC_LIBRARY_DIR
#    BIBLESYNC_VERSION
#
# and the following imported target
#
#     Biblesync::Biblesync
#

# find a directory containing biblesync.hh
find_path(BIBLESYNC_INCLUDE_DIR
  NAMES biblesync.hh
  PATHS ${BIBLESYNC_INCLUDE_DIRS}
  PATH_SUFFIXES biblesync)

# find a library,
# PATHS specify directories to search in addition to the default locations
find_library(BIBLESYNC_LIBRARY_DIR biblesync
  PATHS ${BIBLESYNC_LIBRARY_DIRS})

# set Found
if(BIBLESYNC_INCLUDE_DIR AND BIBLESYNC_LIBRARY_DIR)
  set(BIBLESYNC_FOUND TRUE)
endif()

# set Version
if(BIBLESYNC_INCLUDE_DIR)
  # get string holding version from biblesync-version.hh
  file(STRINGS
    "${BIBLESYNC_INCLUDE_DIR}/biblesync-version.hh"
    _BIBLESYNC_VERSION_STR_CONTENTS
    REGEX "#define BIBLESYNC_VERSION_STR "
    )
  # keep only quoted version
  string(REPLACE
    "#define BIBLESYNC_VERSION_STR "
    ""
    BIBLESYNC_QUOTED_VERSION
    ${_BIBLESYNC_VERSION_STR_CONTENTS}
    )
  # remove quotes
  string(REPLACE
    "\""
    ""
    BIBLESYNC_VERSION
    ${BIBLESYNC_QUOTED_VERSION}
    )
endif()

# Mark the named cached variables as advanced.
# An advanced variable will not be displayed in any of the cmake GUIs
mark_as_advanced(
  BIBLESYNC_FOUND
  BIBLESYNC_INCLUDE_DIR
  BIBLESYNC_LIBRARY_DIR
  BIBLESYNC_VERSION
  )

# handle the REQUIRED and VERSION-related arguments of find_package
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Biblesync
    REQUIRED_VARS BIBLESYNC_INCLUDE_DIR BIBLESYNC_LIBRARY_DIR
    VERSION_VAR BIBLESYNC_VERSION)

# If found, add target
if(BIBLESYNC_FOUND AND NOT TARGET Biblesync::Biblesync)
  add_library(PkgConfig::Biblesync INTERFACE IMPORTED)
  target_include_directories(PkgConfig::Biblesync INTERFACE ${BIBLESYNC_INCLUDE_DIR})
  target_link_libraries(PkgConfig::Biblesync INTERFACE ${BIBLESYNC_LIBRARY_DIR})
endif()