File: FindUlfius.cmake

package info (click to toggle)
glewlwyd 1.4.9-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 16,096 kB
  • sloc: ansic: 14,286; sql: 1,499; sh: 246; makefile: 150
file content (72 lines) | stat: -rw-r--r-- 2,728 bytes parent folder | download | duplicates (2)
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
#.rst:
# FindUlfius
# -----------
#
# Find Ulfius
#
# Find Ulfius headers and libraries.
#
# ::
#
#   ULFIUS_FOUND          - True if Ulfius found.
#   ULFIUS_INCLUDE_DIRS   - Where to find ulfius.h.
#   ULFIUS_LIBRARIES      - List of libraries when using Ulfius.
#   ULFIUS_VERSION_STRING - The version of Ulfius found.

#=============================================================================
# Copyright 2018 Nicolas Mora <mail@babelouest.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation;
# version 2.1 of the License.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
# GNU GENERAL PUBLIC LICENSE for more details.
#
# You should have received a copy of the GNU General Public
# License along with this library.	If not, see <http://www.gnu.org/licenses/>.
#=============================================================================

find_package(PkgConfig QUIET)
pkg_check_modules(PC_ULFIUS QUIET libulfius)

find_path(ULFIUS_INCLUDE_DIR
        NAMES ulfius.h
        HINTS ${PC_ULFIUS_INCLUDEDIR} ${PC_ULFIUS_INCLUDE_DIRS})

find_library(ULFIUS_LIBRARY
        NAMES ulfius libulfius
        HINTS ${PC_ULFIUS_LIBDIR} ${PC_ULFIUS_LIBRARY_DIRS})

set(ULFIUS_VERSION_STRING 0.0.0)
if (PC_ULFIUS_VERSION)
    set(ULFIUS_VERSION_STRING ${PC_ULFIUS_VERSION})
elseif (ULFIUS_INCLUDE_DIR AND EXISTS "${ULFIUS_INCLUDE_DIR}/ulfius.h")
    set(regex_ulfius_version "^#define[ \t]+ULFIUS_VERSION[ \t]+([^\"]+).*")
    file(STRINGS "${ULFIUS_INCLUDE_DIR}/ulfius.h" ulfius_version REGEX "${regex_ulfius_version}")
    string(REGEX REPLACE "${regex_ulfius_version}" "\\1" ULFIUS_VERSION_STRING "${ulfius_version}")
    unset(regex_ulfius_version)
    unset(ulfius_version)
    if (NOT ULFIUS_VERSION_STRING)
        set(regex_ulfius_version "^#define[ \t]+ULFIUS_VERSION[ \t]+([^\"]+).*")
        file(STRINGS "${ULFIUS_INCLUDE_DIR}/ulfius-cfg.h" ulfius_version REGEX "${regex_ulfius_version}")
        string(REGEX REPLACE "${regex_ulfius_version}" "\\1" ULFIUS_VERSION_STRING "${ulfius_version}")
        unset(regex_ulfius_version)
        unset(ulfius_version)
    endif()
endif ()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Ulfius
        REQUIRED_VARS ULFIUS_LIBRARY ULFIUS_INCLUDE_DIR
        VERSION_VAR ULFIUS_VERSION_STRING)

if (ULFIUS_FOUND)
    set(ULFIUS_LIBRARIES ${ULFIUS_LIBRARY})
    set(ULFIUS_INCLUDE_DIRS ${ULFIUS_INCLUDE_DIR})
endif ()

mark_as_advanced(ULFIUS_INCLUDE_DIR ULFIUS_LIBRARY)