-
Notifications
You must be signed in to change notification settings - Fork 200
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
67 lines (55 loc) · 2.1 KB
/
CMakeLists.txt
File metadata and controls
67 lines (55 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
if(NOT NP2SRV_VERSION)
message(FATAL_ERROR "Please use the root CMakeLists file instead.")
endif()
include(CheckFunctionExists)
project(netopeer2-cli C)
# set version
set(NP2CLI_VERSION 2.0.81)
# configure CLI prompt
set(CLI_PROMPT ">" CACHE STRING "Set the CLI prompt (a space is automatically appended at the end)")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cli_config.h.in" "${PROJECT_BINARY_DIR}/cli_config.h" ESCAPE_QUOTES @ONLY)
include_directories(${PROJECT_BINARY_DIR})
# source files
set(CLI_SRC
main.c
commands.c
completion.c
configuration.c
linenoise/linenoise.c
linenoise/utf8.c)
# netopeer2-cli target
add_executable(netopeer2-cli ${CLI_SRC} ${compatsrc})
# reuse server variables
target_link_libraries(netopeer2-cli ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(netopeer2-cli ${LIBYANG_LIBRARIES})
target_link_libraries(netopeer2-cli ${LIBNETCONF2_LIBRARIES})
# dependencies
if(LIBNETCONF2_ENABLED_SSH_TLS)
# - libssh
if(NOT LIBSSH_FOUND)
message(FATAL_ERROR "libnetconf2 supports SSH but libssh was not found, CLI compilation failed!")
endif()
target_link_libraries(netopeer2-cli ${LIBSSH_LIBRARIES})
include_directories(${LIBSSH_INCLUDE_DIRS})
# - SSL library
if (MBEDTLS_FOUND)
# - MbedTLS (has priority over OpenSSL)
target_link_libraries(netopeer2-cli ${MBEDTLS_LIBRARIES})
include_directories(${MBEDTLS_INCLUDE_DIRS})
elseif(OPENSSL_FOUND)
# - OpenSSL
target_link_libraries(netopeer2-cli ${OPENSSL_LIBRARIES})
include_directories(${OPENSSL_INCLUDE_DIR})
else()
message(FATAL_ERROR "libnetconf2 supports TLS but neither MbedTLS nor OpenSSL were found, CLI compilation failed!")
endif()
endif()
# compat checks
check_function_exists(eaccess HAVE_EACCESS)
check_function_exists(mkstemps HAVE_MKSTEMPS)
if(HAVE_MKSTEMPS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_MKSTEMPS")
endif(HAVE_MKSTEMPS)
# install
install(TARGETS netopeer2-cli DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/doc/netopeer2-cli.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)