Michal Vasko | 1130880 | 2016-02-17 14:11:05 +0100 | [diff] [blame] | 1 | # - 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 Krejci | 97df27a | 2016-02-22 16:39:01 +0100 | [diff] [blame] | 7 | # LIBNETCONF2_ENABLED_SSH - LibNETCONF2 was compiled with SSH support |
| 8 | # LIBNETCONF2_ENABLED_TLS - LibNETCONF2 was compiled with TLS support |
Michal Vasko | 1130880 | 2016-02-17 14:11:05 +0100 | [diff] [blame] | 9 | # |
| 10 | # Author Michal Vasko <mvasko@cesnet.cz> |
| 11 | # Copyright (c) 2015 CESNET, z.s.p.o. |
| 12 | # |
| 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 | # |
| 36 | |
Radek Krejci | 97df27a | 2016-02-22 16:39:01 +0100 | [diff] [blame] | 37 | INCLUDE(CheckSymbolExists) |
| 38 | |
Michal Vasko | 1130880 | 2016-02-17 14:11:05 +0100 | [diff] [blame] | 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) |
| 43 | |
| 44 | find_path(LIBNETCONF2_INCLUDE_DIR |
| 45 | NAMES |
| 46 | nc_client.h |
| 47 | nc_server.h |
| 48 | nc_transapi.h |
| 49 | PATHS |
| 50 | /usr/include |
| 51 | /usr/local/include |
| 52 | /opt/local/include |
| 53 | /sw/include |
| 54 | ${CMAKE_INCLUDE_PATH} |
| 55 | ${CMAKE_INSTALL_PREFIX}/include |
| 56 | ) |
| 57 | |
| 58 | find_library(LIBNETCONF2_LIBRARY |
| 59 | NAMES |
| 60 | netconf2 |
| 61 | libnetconf2 |
| 62 | PATHS |
| 63 | /usr/lib |
| 64 | /usr/lib64 |
| 65 | /usr/local/lib |
| 66 | /usr/local/lib64 |
| 67 | /opt/local/lib |
| 68 | /sw/lib |
| 69 | ${CMAKE_LIBRARY_PATH} |
| 70 | ${CMAKE_INSTALL_PREFIX}/lib |
| 71 | ) |
| 72 | |
| 73 | if (LIBNETCONF2_INCLUDE_DIR AND LIBNETCONF2_LIBRARY) |
| 74 | set(LIBNETCONF2_FOUND TRUE) |
| 75 | # check compile flags |
Radek Krejci | 97df27a | 2016-02-22 16:39:01 +0100 | [diff] [blame] | 76 | check_symbol_exists("NC_ENABLED_SSH" "nc_client.h" LIBNETCONF2_ENABLED_SSH) |
| 77 | check_symbol_exists("NC_ENABLED_TLS" "nc_client.h" LIBNETCONF2_ENABLED_TLS) |
Michal Vasko | 1130880 | 2016-02-17 14:11:05 +0100 | [diff] [blame] | 78 | else (LIBNETCONF2_INCLUDE_DIR AND LIBNETCONF2_LIBRARY) |
| 79 | set(LIBNETCONF2_FOUND FALSE) |
| 80 | endif (LIBNETCONF2_INCLUDE_DIR AND LIBNETCONF2_LIBRARY) |
| 81 | |
| 82 | set(LIBNETCONF2_INCLUDE_DIRS ${LIBNETCONF2_INCLUDE_DIR}) |
| 83 | set(LIBNETCONF2_LIBRARIES ${LIBNETCONF2_LIBRARY}) |
| 84 | |
| 85 | # show the LIBNETCONF2_INCLUDE_DIRS and LIBNETCONF2_LIBRARIES variables only in the advanced view |
| 86 | mark_as_advanced(LIBNETCONF2_INCLUDE_DIRS LIBNETCONF2_LIBRARIES) |
| 87 | |
| 88 | endif (LIBNETCONF2_LIBRARIES AND LIBNETCONF2_INCLUDE_DIRS) |
| 89 | |