blob: f09a3b1ca86e91fb791822879f344bc73ce8637b [file] [log] [blame]
Radek Krejcicb293a32020-11-13 15:36:29 +01001# yanglint
2
3set(lintsrc
4 main.c
5 main_ni.c
Radek Krejcie9f13b12020-11-09 17:42:04 +01006 cmd.c
7 cmd_add.c
8 cmd_clear.c
9 cmd_data.c
10 cmd_list.c
11 cmd_load.c
12 cmd_print.c
13 cmd_searchpath.c
14 common.c
Radek Krejcicb293a32020-11-13 15:36:29 +010015 completion.c
16 configuration.c
17 linenoise/linenoise.c)
18
19set(format_sources
20 ${format_sources}
21 ${CMAKE_CURRENT_SOURCE_DIR}/*.c
22 ${CMAKE_CURRENT_SOURCE_DIR}/*.h
23 PARENT_SCOPE)
Michal Vaskob3b3afc2020-11-25 09:52:26 +010024
Michal Vasko1b0b9a12021-05-06 08:38:34 +020025add_executable(yanglint ${lintsrc} ${compatsrc})
Radek Krejcicb293a32020-11-13 15:36:29 +010026target_link_libraries(yanglint yang)
27install(TARGETS yanglint DESTINATION ${CMAKE_INSTALL_BINDIR})
28install(FILES ${PROJECT_SOURCE_DIR}/tools/lint/yanglint.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
29target_include_directories(yanglint BEFORE PRIVATE ${PROJECT_BINARY_DIR})
30
Radek Krejcie868acc2020-11-13 16:42:58 +010031#
32# tests
33#
34function(add_yanglint_test)
35 cmake_parse_arguments(ADDTEST "" "NAME;SCRIPT" "" ${ARGN})
36 set(TEST_NAME yanglint_${ADDTEST_NAME})
37
Michal Vaskob3b3afc2020-11-25 09:52:26 +010038 add_test(NAME ${TEST_NAME} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/${ADDTEST_SCRIPT})
39 set_property(TEST ${TEST_NAME} APPEND PROPERTY ENVIRONMENT "YANGLINT=${PROJECT_BINARY_DIR}/yanglint")
Radek Krejcie868acc2020-11-13 16:42:58 +010040endfunction(add_yanglint_test)
41
Radek Iša2227c662020-11-25 16:13:09 +010042if(ENABLE_BUILD_TESTS)
43 # tests of non-interactive mode using shunit2
44 find_program(PATH_SHUNIT NAMES shunit2)
45 if(NOT PATH_SHUNIT)
46 message(WARNING "'shunit2' not found! The yanglint(1) non-interactive tests will not be available.")
47 else()
48 add_yanglint_test(NAME ni_list SCRIPT shunit2/list.sh)
49 endif()
Radek Krejcie868acc2020-11-13 16:42:58 +010050
Radek Iša2227c662020-11-25 16:13:09 +010051 # tests of interactive mode using expect
52 find_program(PATH_EXPECT NAMES expect)
53 if(NOT PATH_EXPECT)
54 message(WARNING "'expect' not found! The yanglint(1) interactive tests will not be available.")
55 else()
56# add_yanglint_test(NAME in_list SCRIPT expect/list.exp)
57 endif()
Radek Krejcie868acc2020-11-13 16:42:58 +010058endif()