blob: ebacf630a0b038a15554008171f687d3086fb2a0 [file] [log] [blame]
Michal Vasko11308802016-02-17 14:11:05 +01001# - Try to find LibNETCONF2
2# Once done this will define
3#
4# LIBNETCONF2_FOUND - system has LibNETCONF2
5# LIBNETCONF2_INCLUDE_DIRS - the LibNETCONF2 include directory
6# LIBNETCONF2_LIBRARIES - Link these to use LibNETCONF2
Radek Krejci97df27a2016-02-22 16:39:01 +01007# LIBNETCONF2_ENABLED_SSH - LibNETCONF2 was compiled with SSH support
8# LIBNETCONF2_ENABLED_TLS - LibNETCONF2 was compiled with TLS support
Michal Vasko11308802016-02-17 14:11:05 +01009#
10# Author Michal Vasko <mvasko@cesnet.cz>
Michal Vaskob0f5e0e2020-05-05 11:59:17 +020011# Copyright (c) 2020 CESNET, z.s.p.o.
Michal Vasko11308802016-02-17 14:11:05 +010012#
13# Redistribution and use in source and binary forms, with or without
14# modification, are permitted provided that the following conditions
15# are met:
16#
17# 1. Redistributions of source code must retain the copyright
18# notice, this list of conditions and the following disclaimer.
19# 2. Redistributions in binary form must reproduce the copyright
20# notice, this list of conditions and the following disclaimer in the
21# documentation and/or other materials provided with the distribution.
22# 3. The name of the author may not be used to endorse or promote products
23# derived from this software without specific prior written permission.
24#
25# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
26# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
27# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
29# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35#
Michal Vaskob0f5e0e2020-05-05 11:59:17 +020036include(FindPackageHandleStandardArgs)
37include(CheckSymbolExists)
Michal Vasko11308802016-02-17 14:11:05 +010038
Michal Vaskob0f5e0e2020-05-05 11:59:17 +020039if(LIBNETCONF2_LIBRARIES AND LIBNETCONF2_INCLUDE_DIRS)
40 # in cache already
Michal Vasko11308802016-02-17 14:11:05 +010041 set(LIBNETCONF2_FOUND TRUE)
Michal Vaskob0f5e0e2020-05-05 11:59:17 +020042else()
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 )
55
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 )
70
71 set(LIBNETCONF2_INCLUDE_DIRS ${LIBNETCONF2_INCLUDE_DIR})
72 set(LIBNETCONF2_LIBRARIES ${LIBNETCONF2_LIBRARY})
73 mark_as_advanced(LIBNETCONF2_INCLUDE_DIRS LIBNETCONF2_LIBRARIES)
74
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)
78
Michal Vasko2d304e32016-07-26 15:44:16 +020079 # check the configured options and make them available through cmake
80 list(INSERT CMAKE_REQUIRED_INCLUDES 0 "${LIBNETCONF2_INCLUDE_DIR}")
Radek Krejci97df27a2016-02-22 16:39:01 +010081 check_symbol_exists("NC_ENABLED_SSH" "nc_client.h" LIBNETCONF2_ENABLED_SSH)
82 check_symbol_exists("NC_ENABLED_TLS" "nc_client.h" LIBNETCONF2_ENABLED_TLS)
Michal Vasko2d304e32016-07-26 15:44:16 +020083 list(REMOVE_AT CMAKE_REQUIRED_INCLUDES 0)
Michal Vaskob0f5e0e2020-05-05 11:59:17 +020084endif()
Michal Vasko11308802016-02-17 14:11:05 +010085