|
4 | 4 | # LIBNETCONF2_FOUND - system has LibNETCONF2
|
5 | 5 | # LIBNETCONF2_INCLUDE_DIRS - the LibNETCONF2 include directory
|
6 | 6 | # LIBNETCONF2_LIBRARIES - Link these to use LibNETCONF2
|
| 7 | +# LIBNETCONF2_VERSION - SO version of the found libNETCONF2 library |
7 | 8 | # LIBNETCONF2_ENABLED_SSH - LibNETCONF2 was compiled with SSH support
|
8 | 9 | # LIBNETCONF2_ENABLED_TLS - LibNETCONF2 was compiled with TLS support
|
9 | 10 | #
|
10 | 11 | # Author Michal Vasko <[email protected]>
|
11 |
| -# Copyright (c) 2020 CESNET, z.s.p.o. |
| 12 | +# Copyright (c) 2021 CESNET, z.s.p.o. |
12 | 13 | #
|
13 | 14 | # Redistribution and use in source and binary forms, with or without
|
14 | 15 | # modification, are permitted provided that the following conditions
|
|
34 | 35 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
35 | 36 | #
|
36 | 37 | include(FindPackageHandleStandardArgs)
|
37 |
| -include(CheckSymbolExists) |
38 | 38 |
|
39 | 39 | if(LIBNETCONF2_LIBRARIES AND LIBNETCONF2_INCLUDE_DIRS)
|
40 | 40 | # in cache already
|
@@ -68,13 +68,28 @@ else()
|
68 | 68 | ${CMAKE_INSTALL_PREFIX}/lib
|
69 | 69 | )
|
70 | 70 |
|
| 71 | + if(LIBNETCONF2_INCLUDE_DIR) |
| 72 | + find_path(NC_VERSION_PATH "nc_version.h" HINTS ${LIBNETCONF2_INCLUDE_DIR}) |
| 73 | + if(NOT NC_VERSION_PATH) |
| 74 | + message(STATUS "libnetconf2 version header not found, assuming libnetconf2 is too old and cannot be used!") |
| 75 | + set(LIBNETCONF2_INCLUDE_DIR "LIBNETCONF2_INCLUDE_DIR-NOTFOUND") |
| 76 | + set(LIBNETCONF2_LIBRARY "LIBNETCONF2_LIBRARY-NOTFOUND") |
| 77 | + else() |
| 78 | + file(READ "${NC_VERSION_PATH}/nc_version.h" NC_VERSION_FILE) |
| 79 | + string(REGEX MATCH "#define NC_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\"" NC_VERSION_MACRO "${NC_VERSION_FILE}") |
| 80 | + string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" LIBNETCONF2_VERSION "${NC_VERSION_MACRO}") |
| 81 | + endif() |
| 82 | + endif() |
| 83 | + |
71 | 84 | set(LIBNETCONF2_INCLUDE_DIRS ${LIBNETCONF2_INCLUDE_DIR})
|
72 | 85 | set(LIBNETCONF2_LIBRARIES ${LIBNETCONF2_LIBRARY})
|
73 | 86 | mark_as_advanced(LIBNETCONF2_INCLUDE_DIRS LIBNETCONF2_LIBRARIES)
|
74 | 87 |
|
75 | 88 | # handle the QUIETLY and REQUIRED arguments and set SYSREPO_FOUND to TRUE
|
76 | 89 | # if all listed variables are TRUE
|
77 |
| - find_package_handle_standard_args(LibNETCONF2 DEFAULT_MSG LIBNETCONF2_LIBRARY LIBNETCONF2_INCLUDE_DIR) |
| 90 | + find_package_handle_standard_args(LibNETCONF2 FOUND_VAR LIBNETCONF2_FOUND |
| 91 | + REQUIRED_VARS LIBNETCONF2_LIBRARY LIBNETCONF2_INCLUDE_DIR |
| 92 | + VERSION_VAR LIBNETCONF2_VERSION) |
78 | 93 |
|
79 | 94 | # check the configured options and make them available through cmake
|
80 | 95 | list(INSERT CMAKE_REQUIRED_INCLUDES 0 "${LIBNETCONF2_INCLUDE_DIR}")
|
|
0 commit comments