blob: ccf0aeb2deccfe89417b31ae9ecbff200f014d34 [file] [log] [blame]
Jan Kundrátd9d26a92018-02-22 12:49:21 +01001project(netconf-cli LANGUAGES CXX)
2cmake_minimum_required(VERSION 3.0)
Jan Kundrát763db1e2018-05-25 15:43:51 +02003set(CMAKE_CXX_STANDARD 17)
Jan Kundrátd9d26a92018-02-22 12:49:21 +01004set(CMAKE_CXX_STANDARD_REQUIRED ON)
Jan Kundrát8569e1b2020-01-16 13:47:19 +01005set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
Jan Kundrátd47f6552018-03-02 13:40:11 +01006
7include(GNUInstallDirs)
8
9# Set a default build type if none was specified. This was shamelessly stolen
10# from VTK's cmake setup because these guys produce both CMake and a project that
11# manipulates this variable, and the web is full of posts where people say that
12# it is apparently evil to just set the build type in a way an earlier version of
13# this patch did. Oh, and the location of this check/update matters, apparently.
14#
15# Yes, this is just plain crazy.
16if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
17 message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
18 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
19 # Set the possible values of build type for cmake-gui
20 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
21endif()
22
23# -Werror is not a default for sanity reasons (one cannot know what warnings a future compiler
24# might bring along), but it's a default in debug mode. The idea is that developers should care
25# about a warning-free build, and that this is easier than messing with yet another configure option.
26set(CMAKE_CXX_FLAGS_DEBUG "-Werror ${CMAKE_CXX_FLAGS_DEBUG}")
27
28# I don't want to duplicate the compiler's optimizations
29set(CMAKE_CXX_FLAGS "-O2 ${CMAKE_CXX_FLAGS}")
30
31# Build warnings are useful tools (and this project should be warning-free anyway), enable them on all
32# configurations. They are warnings, not errors.
Jan Kundrátfb831902018-05-26 18:58:52 +020033set(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Woverloaded-virtual ${CMAKE_CXX_FLAGS}")
34
35if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
36 set(CMAKE_CXX_FLAGS "-Wsuggest-override ${CMAKE_CXX_FLAGS}")
37endif()
Jan Kundrátd47f6552018-03-02 13:40:11 +010038
Jan Kundrátdc2b0722018-03-02 14:13:37 +010039set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
40
41add_custom_target(git-version-cmake-ide
42 cmake/ProjectGitVersion.cmake
43 cmake/ProjectGitVersionRunner.cmake
44 )
45include(cmake/ProjectGitVersion.cmake)
46prepare_git_version(NETCONF_CLI_VERSION "0.0")
47
Jan Kundrát608818b2018-03-02 13:43:53 +010048find_package(Doxygen)
49option(WITH_DOCS "Create and install internal documentation (needs Doxygen)" ${DOXYGEN_FOUND})
50
Jan Kundrátd47f6552018-03-02 13:40:11 +010051find_package(docopt REQUIRED)
Jan Kundrát03caee82018-03-08 14:16:56 +010052find_package(Boost REQUIRED)
Jan Kundrát8d8efe82019-10-18 10:21:36 +020053find_library(REPLXX_LIBRARY NAMES replxx replxx-d REQUIRED)
Václav Kubernáta395d332019-02-13 16:49:20 +010054find_path(REPLXX_PATH replxx.hxx)
55if("${REPLXX_PATH}" STREQUAL REPLXX_PATH-NOTFOUND)
56 message(FATAL_ERROR "Cannot find the \"replxx.hxx\" include file for the replxx library.")
57endif()
Jan Kundrát608818b2018-03-02 13:43:53 +010058
Jan Kundráte05448a2018-06-13 15:54:33 +020059find_package(PkgConfig)
60pkg_check_modules(LIBYANG REQUIRED libyang-cpp>=0.15.111)
Jan Kundrátbd178362019-02-05 19:00:04 +010061# TODO: bump to 0.7.8 once it is tagged
62pkg_check_modules(SYSREPO REQUIRED libSysrepo-cpp>=0.7.7)
Václav Kubernátc31bd602019-03-07 11:44:48 +010063pkg_check_modules(LIBNETCONF2 REQUIRED libnetconf2>=0.12.47)
Jan Kundráte05448a2018-06-13 15:54:33 +020064
Václav Kubernátb96eef72018-05-04 19:10:22 +020065# we don't need filename tracking, and we prefer to use header-only Boost
66add_definitions(-DBOOST_SPIRIT_X3_NO_FILESYSTEM)
67
Václav Kubernát7edb5372019-12-13 12:40:49 +010068add_library(path STATIC
69 src/ast_path.cpp
70 )
71target_link_libraries(path Boost::boost)
72
73add_library(ast_values STATIC
74 src/ast_values.cpp
75 )
76target_link_libraries(ast_values Boost::boost)
77
78add_library(utils STATIC
79 src/utils.cpp
80 )
81target_link_libraries(utils path Boost::boost)
82
Jan Kundrát578347c2018-08-09 15:02:06 +020083add_library(schemas STATIC
Václav Kubernátbddbb172018-06-13 16:27:39 +020084 src/static_schema.cpp
Václav Kubernát48fc3832018-05-28 14:21:22 +020085 src/schema.cpp
Jan Kundrát578347c2018-08-09 15:02:06 +020086 )
Jan Kundráte5378f62020-01-16 13:46:21 +010087target_link_libraries(schemas PUBLIC path Boost::boost)
Jan Kundrát578347c2018-08-09 15:02:06 +020088
Václav Kubernáte7a9fa32018-08-22 13:56:35 +020089add_library(datastoreaccess STATIC
90 src/datastore_access.cpp
91 )
92target_link_libraries(datastoreaccess PUBLIC Boost::boost)
93
Václav Kubernát80aacc02018-08-22 17:41:54 +020094add_library(sysrepoaccess STATIC
95 src/sysrepo_access.cpp
96 )
Václav Kubernátc31bd602019-03-07 11:44:48 +010097
Václav Kubernát7edb5372019-12-13 12:40:49 +010098target_link_libraries(sysrepoaccess datastoreaccess ast_values ${SYSREPO_LIBRARIES})
Václav Kubernát80aacc02018-08-22 17:41:54 +020099link_directories(${SYSREPO_LIBRARY_DIRS})
100target_include_directories(sysrepoaccess SYSTEM PRIVATE ${SYSREPO_INCLUDE_DIRS})
101
Václav Kubernátc31bd602019-03-07 11:44:48 +0100102add_library(netconfaccess STATIC
103 src/netconf-client.cpp
104 src/netconf_access.cpp
105 )
106
Jan Kundráte5378f62020-01-16 13:46:21 +0100107target_link_libraries(netconfaccess datastoreaccess yangschema ast_values utils ${LIBNETCONF2_LIBRARIES})
Václav Kubernátc31bd602019-03-07 11:44:48 +0100108link_directories(${LIBNETCONF2_LIBRARY_DIRS})
109target_include_directories(netconfaccess SYSTEM PRIVATE ${LIBNETCONF2_INCLUDE_DIRS})
110
Václav Kubernát0d4db442018-07-18 17:18:43 +0200111add_library(yangschema STATIC
112 src/yang_schema.cpp
Václav Kubernát02a71152020-01-21 14:52:51 +0100113 src/libyang_utils.cpp
Václav Kubernát0d4db442018-07-18 17:18:43 +0200114 )
Jan Kundráte5378f62020-01-16 13:46:21 +0100115target_link_libraries(yangschema schemas ${LIBYANG_LIBRARIES})
Václav Kubernát0d4db442018-07-18 17:18:43 +0200116# Ensure that this doesn't override Boost's -isystem -- see the log for details.
117target_include_directories(yangschema SYSTEM PRIVATE ${LIBYANG_INCLUDEDIR})
118link_directories(${LIBYANG_LIBRARY_DIRS})
119
Jan Kundrát578347c2018-08-09 15:02:06 +0200120add_library(parser STATIC
Václav Kubernát48fc3832018-05-28 14:21:22 +0200121 src/parser.cpp
Václav Kubernát24df80e2018-06-06 15:18:03 +0200122 src/ast_commands.cpp
Václav Kubernát195eeea2018-05-18 13:52:36 +0200123 src/parser_context.cpp
Václav Kubernát96344a12018-05-28 16:33:39 +0200124 src/interpreter.cpp
Václav Kubernát329c6c32019-02-06 16:41:53 +0100125 src/ast_handlers.cpp
Jan Kundrátdc2b0722018-03-02 14:13:37 +0100126 )
Václav Kubernát7edb5372019-12-13 12:40:49 +0100127target_link_libraries(parser schemas utils ast_values)
Václav Kubernátd6662962018-03-22 17:41:33 +0100128
Václav Kubernát73109382018-09-14 19:52:03 +0200129
130add_library(sysreposubscription STATIC
131 tests/mock/sysrepo_subscription.cpp
132 )
133
134target_link_libraries(sysreposubscription ${SYSREPO_LIBRARIES})
135link_directories(${SYSREPO_LIBRARY_DIRS})
136target_include_directories(sysreposubscription SYSTEM PRIVATE ${SYSREPO_INCLUDE_DIRS})
137
Jan Kundrátcc4c1f22018-08-09 15:00:03 +0200138add_executable(netconf-cli
Václav Kubernátd6662962018-03-22 17:41:33 +0100139 src/main.cpp
140 )
Václav Kubernáta395d332019-02-13 16:49:20 +0100141target_include_directories(netconf-cli PRIVATE ${REPLXX_PATH})
Václav Kubernátc31bd602019-03-07 11:44:48 +0100142target_link_libraries(netconf-cli netconfaccess sysrepoaccess yangschema docopt parser ${REPLXX_LIBRARY})
Václav Kubernát2b684612018-08-09 18:55:24 +0200143if(CMAKE_CXX_FLAGS MATCHES "-stdlib=libc\\+\\+")
144 target_link_libraries(netconf-cli c++experimental)
145else()
146 target_link_libraries(netconf-cli stdc++fs)
147endif()
148
Jan Kundrátdc2b0722018-03-02 14:13:37 +0100149add_dependencies(netconf-cli target-NETCONF_CLI_VERSION)
150target_include_directories(netconf-cli PRIVATE ${PROJECT_BINARY_DIR})
151
Jan Kundrát5c805212018-03-02 13:57:12 +0100152include(CTest)
153if(BUILD_TESTING)
154 enable_testing()
Jan Kundrátc381e632019-03-14 13:39:11 +0100155 find_package(trompeloeil 33 REQUIRED)
Jan Kundráta33cf082019-03-28 11:55:57 +0100156 find_package(doctest 2.3.1 REQUIRED)
Jan Kundrát5c805212018-03-02 13:57:12 +0100157
Jan Kundráta33cf082019-03-28 11:55:57 +0100158 add_library(DoctestIntegration STATIC
159 tests/doctest_integration.cpp
160 tests/trompeloeil_doctest.h
Jan Kundrátc381e632019-03-14 13:39:11 +0100161 tests/wait-a-bit-longer.cpp
Jan Kundrát5c805212018-03-02 13:57:12 +0100162 )
Jan Kundráta33cf082019-03-28 11:55:57 +0100163 target_include_directories(DoctestIntegration PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/tests/ ${CMAKE_CURRENT_SOURCE_DIR}/src/)
Václav Kubernátc31bd602019-03-07 11:44:48 +0100164 target_link_libraries(DoctestIntegration doctest::doctest trompeloeil)
Jan Kundráta33cf082019-03-28 11:55:57 +0100165 target_compile_definitions(DoctestIntegration PUBLIC DOCTEST_CONFIG_SUPER_FAST_ASSERTS)
Jan Kundrát5c805212018-03-02 13:57:12 +0100166
Václav Kubernát73109382018-09-14 19:52:03 +0200167 if (NOT SYSREPOCTL_EXECUTABLE)
168 find_program(SYSREPOCTL_EXECUTABLE sysrepoctl)
169 endif()
170 if (NOT SYSREPOCTL_EXECUTABLE)
171 message(FATAL_ERROR "Unable to find sysrepoctl, set SYSREPOCTL_EXECUTABLE manually.")
172 endif()
173
Václav Kubernát88324812019-06-26 17:36:29 +0200174 if (NOT SYSREPOCFG_EXECUTABLE)
175 find_program(SYSREPOCFG_EXECUTABLE sysrepocfg)
176 endif()
177 if (NOT SYSREPOCFG_EXECUTABLE)
178 message(FATAL_ERROR "Unable to find sysrepocfg, set SYSREPOCFG_EXECUTABLE manually.")
179 endif()
Václav Kubernát73109382018-09-14 19:52:03 +0200180
Václav Kubernátc31bd602019-03-07 11:44:48 +0100181 if (NOT SYSREPOD_EXECUTABLE)
182 find_program(SYSREPOD_EXECUTABLE sysrepod)
183 endif()
184 if (NOT SYSREPOD_EXECUTABLE)
185 message(FATAL_ERROR "Unable to find sysrepod, set SYSREPOD_EXECUTABLE manually.")
186 endif()
187
188 if (NOT SYSREPO_PLUGIND_EXECUTABLE)
189 find_program(SYSREPO_PLUGIND_EXECUTABLE sysrepo-plugind)
190 endif()
191 if (NOT SYSREPO_PLUGIND_EXECUTABLE)
192 message(FATAL_ERROR "Unable to find sysrepo-plugind, set SYSREPO_EXECUTABLE manually.")
193 endif()
194
195 if (NOT NETOPEER2_EXECUTABLE)
196 find_program(NETOPEER2_EXECUTABLE netopeer2-server)
197 endif()
198 if (NOT NETOPEER2_EXECUTABLE)
199 message(FATAL_ERROR "Unable to find netopeer2-server, set NETOPEER2_EXECUTABLE manually.")
200 endif()
201
Jan Kundráte3236272019-09-27 09:45:26 +0200202 if (NOT FAKEROOT_EXECUTABLE)
203 find_program(FAKEROOT_EXECUTABLE fakeroot)
204 endif()
205 if (NOT FAKEROOT_EXECUTABLE)
206 message(FATAL_ERROR "Unable to find fakeroot, set FAKEROOT_EXECUTABLE manually.")
207 endif()
208
Václav Kubernátc31bd602019-03-07 11:44:48 +0100209 set(NETOPEER_SOCKET_PATH "${CMAKE_CURRENT_BINARY_DIR}/netopeer2-server.sock")
Jan Kundráte1034492020-01-16 23:09:09 +0100210 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tests/start_daemons.sh.in ${CMAKE_CURRENT_BINARY_DIR}/start_daemons.sh @ONLY)
211 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tests/netopeer_vars.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/netopeer_vars.hpp @ONLY)
Václav Kubernátc31bd602019-03-07 11:44:48 +0100212
Václav Kubernát7d478642019-11-22 17:38:11 +0100213 function(setup_datastore_tests)
Jan Kundráte1034492020-01-16 23:09:09 +0100214 add_test(NAME setup_netopeer COMMAND ${SYSREPOCFG_EXECUTABLE} ietf-netconf-server -i ${CMAKE_CURRENT_SOURCE_DIR}/tests/netopeer-test-config.xml --datastore=startup --format=xml)
Václav Kubernát7d478642019-11-22 17:38:11 +0100215 add_test(NAME start_daemons COMMAND ${FAKEROOT_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/start_daemons.sh)
Jan Kundráte1034492020-01-16 23:09:09 +0100216 add_test(NAME kill_daemons COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/kill_daemons.sh)
Václav Kubernát7d478642019-11-22 17:38:11 +0100217 set_tests_properties(setup_netopeer start_daemons kill_daemons PROPERTIES RESOURCE_LOCK sysrepo)
218 set_tests_properties(setup_netopeer PROPERTIES FIXTURES_SETUP netopeer_configured)
219 set_tests_properties(start_daemons PROPERTIES FIXTURES_REQUIRED netopeer_configured FIXTURES_SETUP netopeer_running)
220 endfunction()
221
Václav Kubernát88324812019-06-26 17:36:29 +0200222 function(cli_test name)
223 if (${ARGC} GREATER 1) # this is how CMake does optional arguments
224 add_executable(test_${name}
225 tests/${ARGV1}
226 )
227 else()
228 add_executable(test_${name}
229 tests/${name}.cpp
230 )
Jan Kundrát5c805212018-03-02 13:57:12 +0100231 endif()
Václav Kubernát88324812019-06-26 17:36:29 +0200232 target_link_libraries(test_${name} DoctestIntegration parser)
233 if(NOT CMAKE_CROSSCOMPILING)
234 add_test(test_${name} test_${name})
235 endif()
236 target_include_directories(test_${name} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
Jan Kundrátcc4c1f22018-08-09 15:00:03 +0200237 endfunction()
Václav Kubernát88324812019-06-26 17:36:29 +0200238
Václav Kubernát7d478642019-11-22 17:38:11 +0100239 function(datastore_test_impl name model_path backend)
240 set(TESTNAME test_${name}_${backend})
241 cli_test(${name}_${backend} ${name}.cpp)
242 add_test(NAME ${TESTNAME}_init COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/sysrepoctl-manage-module.sh ${SYSREPOCTL_EXECUTABLE} ${SYSREPOCFG_EXECUTABLE} install ${model_path})
243 add_test(NAME ${TESTNAME}_cleanup COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/sysrepoctl-manage-module.sh ${SYSREPOCTL_EXECUTABLE} ${SYSREPOCFG_EXECUTABLE} uninstall ${model_path})
244 set_tests_properties(${TESTNAME}_init PROPERTIES FIXTURES_REQUIRED netopeer_running FIXTURES_SETUP ${TESTNAME}_setup)
245 set_tests_properties(${TESTNAME} PROPERTIES FIXTURES_REQUIRED ${TESTNAME}_setup RESOURCE_LOCK sysrepo)
246 set_tests_properties(${TESTNAME}_cleanup PROPERTIES FIXTURES_CLEANUP ${TESTNAME}_setup)
247 target_include_directories(${TESTNAME} PRIVATE ${PROJECT_SOURCE_DIR}/tests/mock)
248 if (${backend} STREQUAL "sysrepo")
249 target_link_libraries(${TESTNAME} sysrepoaccess)
250 elseif (${backend} STREQUAL "netconf")
251 target_link_libraries(${TESTNAME} netconfaccess)
252 else()
253 message(FATAL_ERROR "Unknown backend ${backend}")
254 endif()
255 target_link_libraries(${TESTNAME} yangschema sysreposubscription)
256
257 target_compile_definitions(${TESTNAME} PRIVATE ${backend}_BACKEND)
258 endfunction()
259
260 function(datastore_test name model_path)
261 set(TESTNAME test_${name})
Jan Kundráte1034492020-01-16 23:09:09 +0100262 datastore_test_impl(${name} ${CMAKE_CURRENT_SOURCE_DIR}/tests/example-schema.yang sysrepo)
263 datastore_test_impl(${name} ${CMAKE_CURRENT_SOURCE_DIR}/tests/example-schema.yang netconf)
Václav Kubernát7d478642019-11-22 17:38:11 +0100264 set_tests_properties(${TESTNAME}_netconf_init PROPERTIES DEPENDS ${TESTNAME}_sysrepo_cleanup)
Václav Kubernát0177a932020-01-22 11:17:55 +0100265 set_property(TEST kill_daemons APPEND PROPERTY DEPENDS ${TESTNAME}_sysrepo_cleanup)
266 set_property(TEST kill_daemons APPEND PROPERTY DEPENDS ${TESTNAME}_netconf_cleanup)
Václav Kubernát88324812019-06-26 17:36:29 +0200267 endfunction()
268
Václav Kubernátd6662962018-03-22 17:41:33 +0100269 cli_test(cd)
Václav Kubernát11afac72018-07-18 14:59:53 +0200270 cli_test(ls)
Václav Kubernátb61336d2018-05-28 17:35:03 +0200271 cli_test(presence_containers)
Václav Kubernát07204242018-06-04 18:12:09 +0200272 cli_test(leaf_editing)
Václav Kubernát0d4db442018-07-18 17:18:43 +0200273 cli_test(yang)
274 target_link_libraries(test_yang yangschema)
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100275 cli_test(utils)
276 cli_test(path_completion)
Václav Kubernát57272422019-02-08 12:48:24 +0100277 cli_test(command_completion)
Václav Kubernát989b5de2019-02-20 16:28:35 +0100278 cli_test(enum_completion)
Václav Kubernátf5f64f02019-03-19 17:15:47 +0100279 cli_test(list_manipulation)
Václav Kubernát1446fe12019-10-02 19:32:51 +0200280 cli_test(parser_methods)
Václav Kubernát5395e712019-12-03 18:24:33 +0100281 cli_test(path_utils)
Václav Kubernát7edb5372019-12-13 12:40:49 +0100282 target_link_libraries(test_path_utils path)
Václav Kubernátc31bd602019-03-07 11:44:48 +0100283
Václav Kubernát7d478642019-11-22 17:38:11 +0100284 setup_datastore_tests()
Jan Kundráte1034492020-01-16 23:09:09 +0100285 datastore_test(datastore_access ${CMAKE_CURRENT_SOURCE_DIR}/tests/example-schema.yang)
Jan Kundrát5c805212018-03-02 13:57:12 +0100286endif()
287
Jan Kundrátcf5c6362020-01-16 22:54:47 +0100288option(WITH_PYTHON_BINDINGS "Create and install Python3 bindings for accessing datastores" OFF)
289if(WITH_PYTHON_BINDINGS)
290 set(PYBIND11_CPP_STANDARD -std=c++17)
291 find_package(pybind11 REQUIRED)
292 pybind11_add_module(netconf_cli_py src/python_netconf.cpp)
293 target_link_libraries(netconf_cli_py PUBLIC netconfaccess)
294
295 if(BUILD_TESTING)
296 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tests/python_netconfaccess.py
297 ${CMAKE_CURRENT_BINARY_DIR}/tests_python_netconfaccess.py @ONLY)
298 add_test(NAME test_netconf_cli_py COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/tests_python_netconfaccess.py)
299 set_tests_properties(test_netconf_cli_py PROPERTIES FIXTURES_REQUIRED netopeer_running RESOURCE_LOCK sysrepo DEPENDS test_datastore_access_netconf_cleanup)
Václav Kubernát0177a932020-01-22 11:17:55 +0100300 set_property(TEST kill_daemons APPEND PROPERTY DEPENDS test_netconf_cli_py)
Jan Kundrátcf5c6362020-01-16 22:54:47 +0100301
302 set(sanitizer_active OFF)
303 # FIXME: this just sucks. The detection is very unreliable (one could use something like
304 # -fsanitize=address,undefined and we are screwed), and especially clang's query for preload
305 # is obviously unportable because we hardcode host's architecture.
306 # This is super-ugly. Perhaps it would be better just to outright disable everything, but hey,
307 # I need to test this on my laptop where I'm using ASAN by default, and it kinda-almost-works
308 # there with just one patch to libyang :).
309 if (${CMAKE_CXX_FLAGS} MATCHES "-fsanitize=address")
310 set(sanitizer_active ON)
311 set(gcc_sanitizer_preload libasan.so)
312 set(clang_sanitizer_preload libclang_rt.asan-x86_64.so)
313 endif()
314
315 if (sanitizer_active)
316 if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
317 execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=${clang_sanitizer_preload}
318 OUTPUT_VARIABLE LIBxSAN_FULL_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
319 elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
320 execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=${gcc_sanitizer_preload}
321 OUTPUT_VARIABLE LIBxSAN_FULL_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
322 else()
323 message(ERROR "Cannot determine correct sanitizer library for LD_PRELOAD")
324 endif()
325 set_property(TEST test_netconf_cli_py APPEND PROPERTY ENVIRONMENT
326 LD_PRELOAD=${LIBxSAN_FULL_PATH}
327 ASAN_OPTIONS=detect_leaks=0 # they look harmless, but they are annoying
328 )
329 endif()
330 endif()
331endif()
332
Jan Kundrát608818b2018-03-02 13:43:53 +0100333if(WITH_DOCS)
334 set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
335 set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
336 configure_file(${doxyfile_in} ${doxyfile} @ONLY)
337 add_custom_target(doc
338 COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
339 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
340 COMMENT "Generating API documentation with Doxygen"
341 VERBATIM
342 SOURCES ${doxyfile_in}
343 )
344endif()
Jan Kundrát10f49902018-05-22 17:01:45 +0200345
346install(TARGETS
347 netconf-cli
348 RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/)