|
8 | 8 | # LIBNETCONF2_ENABLED_TLS - LibNETCONF2 was compiled with TLS support |
9 | 9 | # |
10 | 10 | # Author Michal Vasko <mvasko@cesnet.cz> |
11 | | -# Copyright (c) 2015 CESNET, z.s.p.o. |
| 11 | +# Copyright (c) 2020 CESNET, z.s.p.o. |
12 | 12 | # |
13 | 13 | # Redistribution and use in source and binary forms, with or without |
14 | 14 | # modification, are permitted provided that the following conditions |
|
33 | 33 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
34 | 34 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
35 | 35 | # |
| 36 | +include(FindPackageHandleStandardArgs) |
| 37 | +include(CheckSymbolExists) |
36 | 38 |
|
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 | + ) |
38 | 55 |
|
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 | + ) |
43 | 70 |
|
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) |
56 | 74 |
|
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) |
71 | 78 |
|
72 | | - if (LIBNETCONF2_INCLUDE_DIR AND LIBNETCONF2_LIBRARY) |
73 | | - set(LIBNETCONF2_FOUND TRUE) |
74 | 79 | # check the configured options and make them available through cmake |
75 | 80 | list(INSERT CMAKE_REQUIRED_INCLUDES 0 "${LIBNETCONF2_INCLUDE_DIR}") |
76 | 81 | check_symbol_exists("NC_ENABLED_SSH" "nc_client.h" LIBNETCONF2_ENABLED_SSH) |
77 | 82 | check_symbol_exists("NC_ENABLED_TLS" "nc_client.h" LIBNETCONF2_ENABLED_TLS) |
78 | 83 | 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() |
90 | 85 |
|
0 commit comments