|
6 | 6 | # LIBYANG_LIBRARIES - Link these to use LibYANG |
7 | 7 | # LIBYANG_VERSION - SO version of the found libyang library |
8 | 8 | # |
| 9 | +# LIBYANG_CPP_FOUND - system has LibYANG C++ bindings |
| 10 | +# LIBYANG_CPP_INCLUDE_DIRS - the LibYANG C++ include directory |
| 11 | +# LIBYANG_CPP_LIBRARIES - Link these to use LibYANG C++ bindings |
| 12 | +# |
9 | 13 | # Author Radek Krejci <[email protected]> |
10 | 14 | # Copyright (c) 2015 CESNET, z.s.p.o. |
11 | 15 | # |
@@ -76,9 +80,54 @@ else() |
76 | 80 | set(LIBYANG_LIBRARIES ${LIBYANG_LIBRARY}) |
77 | 81 | mark_as_advanced(LIBYANG_INCLUDE_DIRS LIBYANG_LIBRARIES) |
78 | 82 |
|
79 | | - # handle the QUIETLY, REQUIRED and VERSION arguments and set LIBYANG_FOUND to TRUE |
| 83 | + # handle the QUIETLY and REQUIRED arguments and set SYSREPO_FOUND to TRUE |
80 | 84 | # if all listed variables are TRUE |
81 | 85 | find_package_handle_standard_args(LibYANG FOUND_VAR LIBYANG_FOUND |
82 | 86 | REQUIRED_VARS LIBYANG_LIBRARY LIBYANG_INCLUDE_DIR |
83 | 87 | VERSION_VAR LIBYANG_VERSION) |
84 | 88 | endif() |
| 89 | + |
| 90 | +#C++ bindings |
| 91 | +if (LIBYANG_CPP_LIBRARIES AND LIBYANG_CPP_INCLUDE_DIRS) |
| 92 | + # in cache already |
| 93 | + set(LIBYANG_CPP_FOUND TRUE) |
| 94 | +else () |
| 95 | + find_path(LIBYANG_CPP_INCLUDE_DIR |
| 96 | + NAMES |
| 97 | + libyang/Libyang.hpp |
| 98 | + PATHS |
| 99 | + /usr/include |
| 100 | + /usr/local/include |
| 101 | + /opt/local/include |
| 102 | + /sw/include |
| 103 | + ${CMAKE_INCLUDE_PATH} |
| 104 | + ${CMAKE_INSTALL_PREFIX}/include |
| 105 | + ) |
| 106 | + |
| 107 | + find_library(LIBYANG_CPP_LIBRARY |
| 108 | + NAMES |
| 109 | + yang-cpp |
| 110 | + libyang-cpp |
| 111 | + PATHS |
| 112 | + /usr/lib |
| 113 | + /usr/lib64 |
| 114 | + /usr/local/lib |
| 115 | + /usr/local/lib64 |
| 116 | + /opt/local/lib |
| 117 | + /sw/lib |
| 118 | + ${CMAKE_LIBRARY_PATH} |
| 119 | + ${CMAKE_INSTALL_PREFIX}/lib |
| 120 | + ) |
| 121 | + |
| 122 | + if (LIBYANG_CPP_INCLUDE_DIR AND LIBYANG_CPP_LIBRARY) |
| 123 | + set(LIBYANG_CPP_FOUND TRUE) |
| 124 | + else () |
| 125 | + set(LIBYANG_CPP_FOUND FALSE) |
| 126 | + endif () |
| 127 | + |
| 128 | + set(LIBYANG_CPP_INCLUDE_DIRS ${LIBYANG_CPP_INCLUDE_DIR}) |
| 129 | + set(LIBYANG_CPP_LIBRARIES ${LIBYANG_CPP_LIBRARY}) |
| 130 | + |
| 131 | + # show the LIBYANG_CPP_INCLUDE_DIRS and LIBYANG_CPP_LIBRARIES variables only in the advanced view |
| 132 | + mark_as_advanced(LIBYANG_CPP_INCLUDE_DIRS LIBYANG_CPP_LIBRARIES) |
| 133 | +endif() |
0 commit comments