Skip to content

Commit b0f5e0e

Browse files
committed
build CHANGE update cmake find modules
1 parent afdbe46 commit b0f5e0e

2 files changed

Lines changed: 83 additions & 87 deletions

File tree

CMakeModules/FindLibYANG.cmake

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# LIBYANG_FOUND - system has LibYANG
55
# LIBYANG_INCLUDE_DIRS - the LibYANG include directory
66
# LIBYANG_LIBRARIES - Link these to use LibYANG
7+
# LIBYANG_VERSION - SO version of the found libyang library
78
#
89
# Author Radek Krejci <rkrejci@cesnet.cz>
910
# Copyright (c) 2015 CESNET, z.s.p.o.
@@ -31,53 +32,53 @@
3132
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3233
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3334
#
35+
include(FindPackageHandleStandardArgs)
3436

3537
if(LIBYANG_LIBRARIES AND LIBYANG_INCLUDE_DIRS)
36-
# in cache already
37-
set(LIBYANG_FOUND TRUE)
38-
else()
39-
40-
find_path(LIBYANG_INCLUDE_DIR
41-
NAMES
42-
libyang/libyang.h
43-
PATHS
44-
/usr/include
45-
/usr/local/include
46-
/opt/local/include
47-
/sw/include
48-
${CMAKE_INCLUDE_PATH}
49-
${CMAKE_INSTALL_PREFIX}/include
50-
)
51-
52-
find_library(LIBYANG_LIBRARY
53-
NAMES
54-
yang
55-
libyang
56-
PATHS
57-
/usr/lib
58-
/usr/lib64
59-
/usr/local/lib
60-
/usr/local/lib64
61-
/opt/local/lib
62-
/sw/lib
63-
${CMAKE_LIBRARY_PATH}
64-
${CMAKE_INSTALL_PREFIX}/lib
65-
)
66-
67-
if(LIBYANG_INCLUDE_DIR AND LIBYANG_LIBRARY)
38+
# in cache already
6839
set(LIBYANG_FOUND TRUE)
69-
else()
70-
set(LIBYANG_FOUND FALSE)
71-
endif()
40+
else()
41+
find_path(LIBYANG_INCLUDE_DIR
42+
NAMES
43+
libyang/libyang.h
44+
PATHS
45+
/usr/include
46+
/usr/local/include
47+
/opt/local/include
48+
/sw/include
49+
${CMAKE_INCLUDE_PATH}
50+
${CMAKE_INSTALL_PREFIX}/include
51+
)
7252

73-
set(LIBYANG_INCLUDE_DIRS ${LIBYANG_INCLUDE_DIR})
74-
set(LIBYANG_LIBRARIES ${LIBYANG_LIBRARY})
53+
find_library(LIBYANG_LIBRARY
54+
NAMES
55+
yang
56+
libyang
57+
PATHS
58+
/usr/lib
59+
/usr/lib64
60+
/usr/local/lib
61+
/usr/local/lib64
62+
/opt/local/lib
63+
/sw/lib
64+
${CMAKE_LIBRARY_PATH}
65+
${CMAKE_INSTALL_PREFIX}/lib
66+
)
7567

76-
include(FindPackageHandleStandardArgs)
77-
find_package_handle_standard_args(LIBYANG DEFAULT_MSG LIBYANG_LIBRARIES LIBYANG_INCLUDE_DIRS)
68+
if(LIBYANG_INCLUDE_DIR)
69+
find_path(LY_HEADER_PATH "libyang/libyang.h" HINTS ${LIBYANG_INCLUDE_DIR})
70+
file(READ "${LY_HEADER_PATH}/libyang/libyang.h" LY_HEADER)
71+
string(REGEX MATCH "#define LY_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\"" LY_VERSION_MACRO "${LY_HEADER}")
72+
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" LIBYANG_VERSION "${LY_VERSION_MACRO}")
73+
endif()
7874

79-
# show the LIBYANG_INCLUDE_DIRS and LIBYANG_LIBRARIES variables only in the advanced view
80-
mark_as_advanced(LIBYANG_INCLUDE_DIRS LIBYANG_LIBRARIES)
75+
set(LIBYANG_INCLUDE_DIRS ${LIBYANG_INCLUDE_DIR})
76+
set(LIBYANG_LIBRARIES ${LIBYANG_LIBRARY})
77+
mark_as_advanced(LIBYANG_INCLUDE_DIRS LIBYANG_LIBRARIES)
8178

79+
# handle the QUIETLY, REQUIRED and VERSION arguments and set LIBYANG_FOUND to TRUE
80+
# if all listed variables are TRUE
81+
find_package_handle_standard_args(LibYANG FOUND_VAR LIBYANG_FOUND
82+
REQUIRED_VARS LIBYANG_LIBRARY LIBYANG_INCLUDE_DIR
83+
VERSION_VAR LIBYANG_VERSION)
8284
endif()
83-

FindLibNETCONF2.cmake

Lines changed: 40 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# LIBNETCONF2_ENABLED_TLS - LibNETCONF2 was compiled with TLS support
99
#
1010
# Author Michal Vasko <mvasko@cesnet.cz>
11-
# Copyright (c) 2015 CESNET, z.s.p.o.
11+
# Copyright (c) 2020 CESNET, z.s.p.o.
1212
#
1313
# Redistribution and use in source and binary forms, with or without
1414
# modification, are permitted provided that the following conditions
@@ -33,58 +33,53 @@
3333
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3434
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3535
#
36+
include(FindPackageHandleStandardArgs)
37+
include(CheckSymbolExists)
3638

37-
INCLUDE(CheckSymbolExists)
39+
if(LIBNETCONF2_LIBRARIES AND LIBNETCONF2_INCLUDE_DIRS)
40+
# in cache already
41+
set(LIBNETCONF2_FOUND TRUE)
42+
else()
43+
find_path(LIBNETCONF2_INCLUDE_DIR
44+
NAMES
45+
nc_client.h
46+
nc_server.h
47+
PATHS
48+
/usr/include
49+
/usr/local/include
50+
/opt/local/include
51+
/sw/include
52+
${CMAKE_INCLUDE_PATH}
53+
${CMAKE_INSTALL_PREFIX}/include
54+
)
3855

39-
if (LIBNETCONF2_LIBRARIES AND LIBNETCONF2_INCLUDE_DIRS)
40-
# in cache already
41-
set(LIBNETCONF2_FOUND TRUE)
42-
else (LIBNETCONF2_LIBRARIES AND LIBNETCONF2_INCLUDE_DIRS)
56+
find_library(LIBNETCONF2_LIBRARY
57+
NAMES
58+
netconf2
59+
libnetconf2
60+
PATHS
61+
/usr/lib
62+
/usr/lib64
63+
/usr/local/lib
64+
/usr/local/lib64
65+
/opt/local/lib
66+
/sw/lib
67+
${CMAKE_LIBRARY_PATH}
68+
${CMAKE_INSTALL_PREFIX}/lib
69+
)
4370

44-
find_path(LIBNETCONF2_INCLUDE_DIR
45-
NAMES
46-
nc_client.h
47-
nc_server.h
48-
PATHS
49-
/usr/include
50-
/usr/local/include
51-
/opt/local/include
52-
/sw/include
53-
${CMAKE_INCLUDE_PATH}
54-
${CMAKE_INSTALL_PREFIX}/include
55-
)
71+
set(LIBNETCONF2_INCLUDE_DIRS ${LIBNETCONF2_INCLUDE_DIR})
72+
set(LIBNETCONF2_LIBRARIES ${LIBNETCONF2_LIBRARY})
73+
mark_as_advanced(LIBNETCONF2_INCLUDE_DIRS LIBNETCONF2_LIBRARIES)
5674

57-
find_library(LIBNETCONF2_LIBRARY
58-
NAMES
59-
netconf2
60-
libnetconf2
61-
PATHS
62-
/usr/lib
63-
/usr/lib64
64-
/usr/local/lib
65-
/usr/local/lib64
66-
/opt/local/lib
67-
/sw/lib
68-
${CMAKE_LIBRARY_PATH}
69-
${CMAKE_INSTALL_PREFIX}/lib
70-
)
75+
# handle the QUIETLY and REQUIRED arguments and set SYSREPO_FOUND to TRUE
76+
# if all listed variables are TRUE
77+
find_package_handle_standard_args(LibNETCONF2 DEFAULT_MSG LIBNETCONF2_LIBRARY LIBNETCONF2_INCLUDE_DIR)
7178

72-
if (LIBNETCONF2_INCLUDE_DIR AND LIBNETCONF2_LIBRARY)
73-
set(LIBNETCONF2_FOUND TRUE)
7479
# check the configured options and make them available through cmake
7580
list(INSERT CMAKE_REQUIRED_INCLUDES 0 "${LIBNETCONF2_INCLUDE_DIR}")
7681
check_symbol_exists("NC_ENABLED_SSH" "nc_client.h" LIBNETCONF2_ENABLED_SSH)
7782
check_symbol_exists("NC_ENABLED_TLS" "nc_client.h" LIBNETCONF2_ENABLED_TLS)
7883
list(REMOVE_AT CMAKE_REQUIRED_INCLUDES 0)
79-
else (LIBNETCONF2_INCLUDE_DIR AND LIBNETCONF2_LIBRARY)
80-
set(LIBNETCONF2_FOUND FALSE)
81-
endif (LIBNETCONF2_INCLUDE_DIR AND LIBNETCONF2_LIBRARY)
82-
83-
set(LIBNETCONF2_INCLUDE_DIRS ${LIBNETCONF2_INCLUDE_DIR})
84-
set(LIBNETCONF2_LIBRARIES ${LIBNETCONF2_LIBRARY})
85-
86-
# show the LIBNETCONF2_INCLUDE_DIRS and LIBNETCONF2_LIBRARIES variables only in the advanced view
87-
mark_as_advanced(LIBNETCONF2_INCLUDE_DIRS LIBNETCONF2_LIBRARIES)
88-
89-
endif (LIBNETCONF2_LIBRARIES AND LIBNETCONF2_INCLUDE_DIRS)
84+
endif()
9085

0 commit comments

Comments
 (0)