forked from CESNET/netopeer2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
56 lines (46 loc) · 1.73 KB
/
CMakeLists.txt
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
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.64)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cli_version.h.in" "${PROJECT_BINARY_DIR}/cli_version.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)
# 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 - libssh
if(LIBNETCONF2_ENABLED_SSH)
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})
endif()
# dependencies - libssl
if(LIBNETCONF2_ENABLED_TLS)
if(NOT OPENSSL_FOUND)
message(FATAL_ERROR "libnetconf2 supports TLS but OpenSSL was not found, CLI compilation failed!")
endif()
target_link_libraries(netopeer2-cli ${OPENSSL_LIBRARIES})
include_directories(${OPENSSL_INCLUDE_DIR})
endif()
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)