Skip to content

Commit 0599d13

Browse files
committed
cmake CHANGE find module C++ bindings search
1 parent 09aa184 commit 0599d13

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

FindLibYANG.cmake

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
# LIBYANG_LIBRARIES - Link these to use LibYANG
77
# LIBYANG_VERSION - SO version of the found libyang library
88
#
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+
#
913
# Author Radek Krejci <[email protected]>
1014
# Copyright (c) 2015 CESNET, z.s.p.o.
1115
#
@@ -76,9 +80,54 @@ else()
7680
set(LIBYANG_LIBRARIES ${LIBYANG_LIBRARY})
7781
mark_as_advanced(LIBYANG_INCLUDE_DIRS LIBYANG_LIBRARIES)
7882

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
8084
# if all listed variables are TRUE
8185
find_package_handle_standard_args(LibYANG FOUND_VAR LIBYANG_FOUND
8286
REQUIRED_VARS LIBYANG_LIBRARY LIBYANG_INCLUDE_DIR
8387
VERSION_VAR LIBYANG_VERSION)
8488
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

Comments
 (0)