Radek Krejci | cb293a3 | 2020-11-13 15:36:29 +0100 | [diff] [blame] | 1 | # yanglint |
| 2 | |
| 3 | set(lintsrc |
| 4 | main.c |
| 5 | main_ni.c |
Radek Krejci | e9f13b1 | 2020-11-09 17:42:04 +0100 | [diff] [blame] | 6 | cmd.c |
| 7 | cmd_add.c |
| 8 | cmd_clear.c |
| 9 | cmd_data.c |
| 10 | cmd_list.c |
Michal Vasko | 538be42 | 2021-10-19 14:06:59 +0200 | [diff] [blame] | 11 | cmd_feature.c |
Radek Krejci | e9f13b1 | 2020-11-09 17:42:04 +0100 | [diff] [blame] | 12 | cmd_load.c |
| 13 | cmd_print.c |
| 14 | cmd_searchpath.c |
| 15 | common.c |
Radek Krejci | cb293a3 | 2020-11-13 15:36:29 +0100 | [diff] [blame] | 16 | completion.c |
| 17 | configuration.c |
| 18 | linenoise/linenoise.c) |
| 19 | |
| 20 | set(format_sources |
| 21 | ${format_sources} |
| 22 | ${CMAKE_CURRENT_SOURCE_DIR}/*.c |
| 23 | ${CMAKE_CURRENT_SOURCE_DIR}/*.h |
| 24 | PARENT_SCOPE) |
Michal Vasko | b3b3afc | 2020-11-25 09:52:26 +0100 | [diff] [blame] | 25 | |
Michal Vasko | 1b0b9a1 | 2021-05-06 08:38:34 +0200 | [diff] [blame] | 26 | add_executable(yanglint ${lintsrc} ${compatsrc}) |
Radek Krejci | cb293a3 | 2020-11-13 15:36:29 +0100 | [diff] [blame] | 27 | target_link_libraries(yanglint yang) |
| 28 | install(TARGETS yanglint DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 29 | install(FILES ${PROJECT_SOURCE_DIR}/tools/lint/yanglint.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) |
| 30 | target_include_directories(yanglint BEFORE PRIVATE ${PROJECT_BINARY_DIR}) |
| 31 | |
Radek Krejci | e868acc | 2020-11-13 16:42:58 +0100 | [diff] [blame] | 32 | # |
| 33 | # tests |
| 34 | # |
| 35 | function(add_yanglint_test) |
| 36 | cmake_parse_arguments(ADDTEST "" "NAME;SCRIPT" "" ${ARGN}) |
| 37 | set(TEST_NAME yanglint_${ADDTEST_NAME}) |
| 38 | |
Michal Vasko | b3b3afc | 2020-11-25 09:52:26 +0100 | [diff] [blame] | 39 | add_test(NAME ${TEST_NAME} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/${ADDTEST_SCRIPT}) |
| 40 | set_property(TEST ${TEST_NAME} APPEND PROPERTY ENVIRONMENT "YANGLINT=${PROJECT_BINARY_DIR}/yanglint") |
Radek Krejci | e868acc | 2020-11-13 16:42:58 +0100 | [diff] [blame] | 41 | endfunction(add_yanglint_test) |
| 42 | |
Michal Vasko | cdffdab | 2021-06-23 14:00:10 +0200 | [diff] [blame] | 43 | if(ENABLE_TESTS) |
Radek Iša | 2227c66 | 2020-11-25 16:13:09 +0100 | [diff] [blame] | 44 | # tests of non-interactive mode using shunit2 |
| 45 | find_program(PATH_SHUNIT NAMES shunit2) |
| 46 | if(NOT PATH_SHUNIT) |
| 47 | message(WARNING "'shunit2' not found! The yanglint(1) non-interactive tests will not be available.") |
| 48 | else() |
| 49 | add_yanglint_test(NAME ni_list SCRIPT shunit2/list.sh) |
| 50 | endif() |
Radek Krejci | e868acc | 2020-11-13 16:42:58 +0100 | [diff] [blame] | 51 | |
Radek Iša | 2227c66 | 2020-11-25 16:13:09 +0100 | [diff] [blame] | 52 | # tests of interactive mode using expect |
| 53 | find_program(PATH_EXPECT NAMES expect) |
| 54 | if(NOT PATH_EXPECT) |
| 55 | message(WARNING "'expect' not found! The yanglint(1) interactive tests will not be available.") |
| 56 | else() |
| 57 | # add_yanglint_test(NAME in_list SCRIPT expect/list.exp) |
| 58 | endif() |
Radek Krejci | e868acc | 2020-11-13 16:42:58 +0100 | [diff] [blame] | 59 | endif() |