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 |
| 11 | cmd_load.c |
| 12 | cmd_print.c |
| 13 | cmd_searchpath.c |
| 14 | common.c |
Radek Krejci | cb293a3 | 2020-11-13 15:36:29 +0100 | [diff] [blame] | 15 | completion.c |
| 16 | configuration.c |
| 17 | linenoise/linenoise.c) |
| 18 | |
| 19 | set(format_sources |
| 20 | ${format_sources} |
| 21 | ${CMAKE_CURRENT_SOURCE_DIR}/*.c |
| 22 | ${CMAKE_CURRENT_SOURCE_DIR}/*.h |
| 23 | PARENT_SCOPE) |
Michal Vasko | b3b3afc | 2020-11-25 09:52:26 +0100 | [diff] [blame] | 24 | |
Radek Krejci | cb293a3 | 2020-11-13 15:36:29 +0100 | [diff] [blame] | 25 | add_executable(yanglint ${lintsrc} $<TARGET_OBJECTS:compat>) |
| 26 | target_link_libraries(yanglint yang) |
| 27 | install(TARGETS yanglint DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 28 | install(FILES ${PROJECT_SOURCE_DIR}/tools/lint/yanglint.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) |
| 29 | target_include_directories(yanglint BEFORE PRIVATE ${PROJECT_BINARY_DIR}) |
| 30 | |
Radek Krejci | e868acc | 2020-11-13 16:42:58 +0100 | [diff] [blame] | 31 | # |
| 32 | # tests |
| 33 | # |
| 34 | function(add_yanglint_test) |
| 35 | cmake_parse_arguments(ADDTEST "" "NAME;SCRIPT" "" ${ARGN}) |
| 36 | set(TEST_NAME yanglint_${ADDTEST_NAME}) |
| 37 | |
Michal Vasko | b3b3afc | 2020-11-25 09:52:26 +0100 | [diff] [blame] | 38 | 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 Krejci | e868acc | 2020-11-13 16:42:58 +0100 | [diff] [blame] | 40 | endfunction(add_yanglint_test) |
| 41 | |
| 42 | # tests of non-interactive mode using shunit2 |
| 43 | find_program(PATH_SHUNIT NAMES shunit2) |
| 44 | if(NOT PATH_SHUNIT) |
Michal Vasko | b3b3afc | 2020-11-25 09:52:26 +0100 | [diff] [blame] | 45 | message(WARNING "'shunit2' not found! The yanglint(1) non-interactive tests will not be available.") |
Radek Krejci | e868acc | 2020-11-13 16:42:58 +0100 | [diff] [blame] | 46 | else() |
Michal Vasko | b3b3afc | 2020-11-25 09:52:26 +0100 | [diff] [blame] | 47 | add_yanglint_test(NAME ni_list SCRIPT shunit2/list.sh) |
Radek Krejci | e868acc | 2020-11-13 16:42:58 +0100 | [diff] [blame] | 48 | endif() |
| 49 | |
| 50 | # tests of interactive mode using expect |
Michal Vasko | b3b3afc | 2020-11-25 09:52:26 +0100 | [diff] [blame] | 51 | find_program(PATH_EXPECT NAMES expect) |
| 52 | if(NOT PATH_EXPECT) |
| 53 | message(WARNING "'expect' not found! The yanglint(1) interactive tests will not be available.") |
Radek Krejci | e868acc | 2020-11-13 16:42:58 +0100 | [diff] [blame] | 54 | else() |
Michal Vasko | b3b3afc | 2020-11-25 09:52:26 +0100 | [diff] [blame] | 55 | add_yanglint_test(NAME in_list SCRIPT expect/list.exp) |
Radek Krejci | e868acc | 2020-11-13 16:42:58 +0100 | [diff] [blame] | 56 | endif() |