Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 1 | project(velia LANGUAGES CXX) |
Tomáš Pecka | 9fa5f6a | 2021-04-13 11:36:11 +0200 | [diff] [blame] | 2 | cmake_minimum_required(VERSION 3.19) |
| 3 | cmake_policy(SET CMP0109 NEW) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 4 | |
| 5 | # Build options |
Václav Kubernát | b332d98 | 2021-04-16 01:40:11 +0200 | [diff] [blame] | 6 | set(CMAKE_CXX_STANDARD 20) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 7 | set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 8 | |
| 9 | set(CMAKE_CXX_FLAGS_DEBUG "-Werror ${CMAKE_CXX_FLAGS_DEBUG}") |
Václav Kubernát | d4b8a69 | 2021-04-16 01:21:44 +0200 | [diff] [blame] | 10 | set(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Woverloaded-virtual -Wimplicit-fallthrough ${CMAKE_CXX_FLAGS}") |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 11 | if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") |
| 12 | set(CMAKE_CXX_FLAGS "-Wsuggest-override ${CMAKE_CXX_FLAGS}") |
| 13 | endif() |
| 14 | |
Tomáš Pecka | 5d4cf2a | 2020-07-13 13:19:41 +0200 | [diff] [blame] | 15 | if(CMAKE_CXX_FLAGS MATCHES "-stdlib=libc\\+\\+" AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) |
| 16 | set(STD_FILESYSTEM_LIBRARY c++fs) |
| 17 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.1) |
| 18 | set(STD_FILESYSTEM_LIBRARY stdc++fs) |
| 19 | endif() |
| 20 | |
| 21 | |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 22 | add_custom_target(velia-version-cmake-ide |
| 23 | cmake/ProjectGitVersion.cmake |
| 24 | cmake/ProjectGitVersionRunner.cmake |
| 25 | ) |
| 26 | include(cmake/ProjectGitVersion.cmake) |
| 27 | prepare_git_version(VELIA_VERSION "0.0") |
| 28 | |
| 29 | find_package(Doxygen) |
| 30 | option(WITH_DOCS "Create and install internal documentation (needs Doxygen)" ${DOXYGEN_FOUND}) |
| 31 | |
Václav Kubernát | de0e4e6 | 2021-02-08 17:46:14 +0100 | [diff] [blame] | 32 | find_package(Boost REQUIRED) |
Tomáš Pecka | a193c03 | 2020-06-22 17:33:31 +0200 | [diff] [blame] | 33 | find_package(docopt REQUIRED) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 34 | find_package(spdlog REQUIRED) |
Tomáš Pecka | 6a266d8 | 2021-11-19 11:35:39 +0100 | [diff] [blame] | 35 | find_package(sdbus-c++ "1.0.0" REQUIRED) |
Tomáš Pecka | a433681 | 2020-07-24 15:32:58 +0200 | [diff] [blame] | 36 | find_package(PkgConfig) |
Václav Kubernát | babbab9 | 2021-01-27 09:25:05 +0100 | [diff] [blame] | 37 | find_package(fmt) |
Tomáš Pecka | a433681 | 2020-07-24 15:32:58 +0200 | [diff] [blame] | 38 | |
| 39 | pkg_check_modules(SYSTEMD REQUIRED IMPORTED_TARGET libsystemd) |
Tomáš Pecka | 1f42cfe | 2020-10-21 18:38:27 +0200 | [diff] [blame] | 40 | if(${SYSTEMD_VERSION} VERSION_EQUAL 245) |
| 41 | message(FATAL_ERROR "Systemd 245 has a bug affecting DBus method calls using sdbus-c++. Please see https://github.com/Kistler-Group/sdbus-cpp/issues/106.") |
| 42 | endif() |
Tomáš Pecka | 070f60d | 2021-10-13 21:48:14 +0200 | [diff] [blame] | 43 | #TODO: Check patch 20333 active |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 44 | |
Jan Kundrát | 5681a50 | 2021-10-01 01:38:22 +0200 | [diff] [blame] | 45 | pkg_check_modules(SYSREPO REQUIRED sysrepo-cpp>=1.4.148 IMPORTED_TARGET sysrepo) |
| 46 | pkg_check_modules(LIBYANG REQUIRED libyang-cpp>=1.0.248 IMPORTED_TARGET libyang) |
Tomáš Pecka | 2d578c8 | 2021-02-23 19:01:35 +0100 | [diff] [blame] | 47 | pkg_check_modules(LIBNL REQUIRED IMPORTED_TARGET libnl-route-3.0) |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 48 | |
Tomáš Pecka | c927d66 | 2020-07-13 11:16:16 +0200 | [diff] [blame] | 49 | include(GNUInstallDirs) |
| 50 | |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 51 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/) |
| 52 | |
Tomáš Pecka | 73a13cc | 2020-11-17 11:12:19 +0100 | [diff] [blame] | 53 | set(YANG_SRCS |
Tomáš Pecka | 9a02c3f | 2021-01-21 15:27:22 +0100 | [diff] [blame] | 54 | yang/czechlight-system@2021-01-13.yang |
Tomáš Pecka | 73a13cc | 2020-11-17 11:12:19 +0100 | [diff] [blame] | 55 | yang/iana-hardware@2018-03-13.yang |
Tomáš Pecka | 73a13cc | 2020-11-17 11:12:19 +0100 | [diff] [blame] | 56 | yang/ietf-hardware@2018-03-13.yang |
Tomáš Pecka | f98ce03 | 2021-01-14 13:35:00 +0100 | [diff] [blame] | 57 | yang/iana-crypt-hash@2014-08-06.yang |
| 58 | yang/ietf-inet-types@2013-07-15.yang |
| 59 | yang/ietf-netconf-acm@2018-02-14.yang |
| 60 | yang/ietf-system@2014-08-06.yang |
| 61 | yang/ietf-yang-types@2013-07-15.yang |
Tomáš Pecka | 435ca2a | 2021-01-27 10:53:48 +0100 | [diff] [blame] | 62 | yang/ietf-ethertypes@2019-03-04.yang |
| 63 | yang/ietf-interfaces@2018-02-20.yang |
| 64 | yang/ietf-packet-fields@2019-03-04.yang |
Václav Kubernát | 637fe80 | 2021-01-22 02:43:18 +0100 | [diff] [blame] | 65 | yang/ietf-access-control-list@2019-03-04.yang |
Václav Kubernát | 457d1ad | 2021-01-22 02:43:18 +0100 | [diff] [blame] | 66 | yang/czechlight-firewall@2021-01-25.yang |
Tomáš Pecka | dac27d4 | 2021-02-22 13:20:05 +0100 | [diff] [blame] | 67 | yang/czechlight-network@2021-02-22.yang |
| 68 | yang/iana-if-type@2017-01-19.yang |
| 69 | yang/ietf-ip@2018-02-22.yang |
Tomáš Pecka | 2a4ea7b | 2021-03-30 17:01:37 +0200 | [diff] [blame] | 70 | yang/ietf-routing@2018-03-13.yang |
| 71 | yang/ietf-ipv4-unicast-routing@2018-03-13.yang |
| 72 | yang/ietf-ipv6-unicast-routing@2018-03-13.yang |
Tomáš Pecka | 7acf392 | 2021-08-10 11:16:57 +0200 | [diff] [blame] | 73 | yang/czechlight-lldp@2020-11-04.yang |
| 74 | yang/iana-afn-safi@2013-07-04.yang |
Tomáš Pecka | 73a13cc | 2020-11-17 11:12:19 +0100 | [diff] [blame] | 75 | ) |
| 76 | |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 77 | # Targets |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 78 | # - utils |
Tomáš Pecka | bd82886 | 2020-06-15 15:53:35 +0200 | [diff] [blame] | 79 | add_library(velia-utils STATIC |
Tomáš Pecka | a193c03 | 2020-06-22 17:33:31 +0200 | [diff] [blame] | 80 | src/utils/exceptions.cpp |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 81 | src/utils/exceptions.h |
Václav Kubernát | 6d9357e | 2021-01-28 15:38:24 +0100 | [diff] [blame] | 82 | src/utils/exec.cpp |
| 83 | src/utils/exec.h |
Tomáš Pecka | 491f4f2 | 2020-11-05 15:44:00 +0100 | [diff] [blame] | 84 | src/utils/io.cpp |
| 85 | src/utils/io.h |
Tomáš Pecka | a433681 | 2020-07-24 15:32:58 +0200 | [diff] [blame] | 86 | src/utils/journal.cpp |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 87 | src/utils/journal.h |
Václav Kubernát | cbdc98a | 2021-01-28 13:24:37 +0100 | [diff] [blame] | 88 | src/utils/libyang.cpp |
| 89 | src/utils/libyang.h |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 90 | src/utils/log.h |
Václav Kubernát | 6018f08 | 2021-02-11 01:32:18 +0100 | [diff] [blame] | 91 | src/utils/log.cpp |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 92 | src/utils/log-fwd.h |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 93 | src/utils/log-init.cpp |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 94 | src/utils/log-init.h |
Tomáš Pecka | ba2dc31 | 2021-01-23 22:29:11 +0100 | [diff] [blame] | 95 | src/utils/sysrepo.cpp |
| 96 | src/utils/sysrepo.h |
Tomáš Pecka | 339bc67 | 2020-11-11 15:59:03 +0100 | [diff] [blame] | 97 | src/utils/time.cpp |
| 98 | src/utils/time.h |
Tomáš Pecka | d033707 | 2021-01-25 19:57:00 +0100 | [diff] [blame] | 99 | src/utils/waitUntilSignalled.cpp |
| 100 | src/utils/waitUntilSignalled.h |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 101 | ) |
Václav Kubernát | 6018f08 | 2021-02-11 01:32:18 +0100 | [diff] [blame] | 102 | target_link_libraries(velia-utils PUBLIC spdlog::spdlog PRIVATE PkgConfig::SYSTEMD PkgConfig::SYSREPO fmt::fmt docopt) |
Tomáš Pecka | a433681 | 2020-07-24 15:32:58 +0200 | [diff] [blame] | 103 | |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 104 | # - health |
| 105 | add_library(velia-health STATIC |
| 106 | src/health/inputs/AbstractInput.cpp |
| 107 | src/health/inputs/DbusSemaphoreInput.cpp |
| 108 | src/health/inputs/DbusSystemdInput.cpp |
| 109 | src/health/manager/AbstractManager.cpp |
| 110 | src/health/manager/StateManager.cpp |
| 111 | src/health/outputs/LedSysfsDriver.cpp |
| 112 | src/health/outputs/callables.cpp |
| 113 | src/health/State.cpp |
Tomáš Pecka | 74b885f | 2020-06-06 20:02:41 +0200 | [diff] [blame] | 114 | ) |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 115 | target_link_libraries(velia-health |
| 116 | PUBLIC |
| 117 | velia-utils |
| 118 | Boost::boost |
| 119 | SDBusCpp::sdbus-c++ |
| 120 | ${STD_FILESYSTEM_LIBRARY} |
| 121 | ) |
Tomáš Pecka | 74b885f | 2020-06-06 20:02:41 +0200 | [diff] [blame] | 122 | |
Tomáš Pecka | 491f4f2 | 2020-11-05 15:44:00 +0100 | [diff] [blame] | 123 | # - ietf-hardware |
| 124 | add_library(velia-ietf-hardware STATIC |
| 125 | src/ietf-hardware/sysfs/EMMC.cpp |
| 126 | src/ietf-hardware/sysfs/EMMC.h |
Tomáš Pecka | 9b1c967 | 2020-11-11 15:24:06 +0100 | [diff] [blame] | 127 | src/ietf-hardware/sysfs/HWMon.cpp |
| 128 | src/ietf-hardware/sysfs/HWMon.h |
Tomáš Pecka | 339bc67 | 2020-11-11 15:59:03 +0100 | [diff] [blame] | 129 | src/ietf-hardware/IETFHardware.cpp |
| 130 | src/ietf-hardware/IETFHardware.h |
Václav Kubernát | 97e5ea1 | 2021-03-24 00:36:57 +0100 | [diff] [blame] | 131 | src/ietf-hardware/FspYhPsu.cpp |
| 132 | src/ietf-hardware/FspYhPsu.h |
Tomáš Pecka | 491f4f2 | 2020-11-05 15:44:00 +0100 | [diff] [blame] | 133 | ) |
| 134 | target_link_libraries(velia-ietf-hardware |
| 135 | PUBLIC |
| 136 | velia-utils |
| 137 | ${STD_FILESYSTEM_LIBRARY} |
Tomáš Pecka | 9b1c967 | 2020-11-11 15:24:06 +0100 | [diff] [blame] | 138 | Boost::boost |
Tomáš Pecka | 491f4f2 | 2020-11-05 15:44:00 +0100 | [diff] [blame] | 139 | ) |
Tomáš Pecka | 491f4f2 | 2020-11-05 15:44:00 +0100 | [diff] [blame] | 140 | |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 141 | add_library(velia-ietf-hardware-sysrepo STATIC |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 142 | src/ietf-hardware/sysrepo/Sysrepo.cpp |
| 143 | src/ietf-hardware/sysrepo/Sysrepo.h |
| 144 | ) |
| 145 | target_link_libraries(velia-ietf-hardware-sysrepo |
| 146 | PUBLIC |
| 147 | velia-utils |
| 148 | PkgConfig::SYSREPO |
| 149 | PkgConfig::LIBYANG |
| 150 | ) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 151 | |
Václav Kubernát | 6d9357e | 2021-01-28 15:38:24 +0100 | [diff] [blame] | 152 | set(NOBODY_UID 65534 CACHE STRING "UID which refers to 'nobody'. Used for dropping root privileges.") |
| 153 | set(NOBODY_GID 65534 CACHE STRING "GID which refers to 'nobody'. Used for dropping root privileges.") |
| 154 | |
Václav Kubernát | de0e4e6 | 2021-02-08 17:46:14 +0100 | [diff] [blame] | 155 | if(NOT NFT_EXECUTABLE) |
| 156 | find_program(NFT_EXECUTABLE nft) |
| 157 | endif() |
Václav Kubernát | babbab9 | 2021-01-27 09:25:05 +0100 | [diff] [blame] | 158 | if(NOT SSH_KEYGEN_EXECUTABLE) |
| 159 | find_program(SSH_KEYGEN_EXECUTABLE ssh-keygen) |
| 160 | endif() |
| 161 | if(NOT CHPASSWD_EXECUTABLE) |
| 162 | find_program(CHPASSWD_EXECUTABLE chpasswd) |
| 163 | endif() |
Tomáš Pecka | 879a603 | 2021-02-03 17:21:48 +0100 | [diff] [blame] | 164 | if(NOT SYSTEMCTL_EXECUTABLE) |
| 165 | find_program(SYSTEMCTL_EXECUTABLE systemctl) |
| 166 | endif() |
Tomáš Pecka | 5c19e72 | 2021-02-15 20:41:29 +0100 | [diff] [blame] | 167 | if(NOT NETWORKCTL_EXECUTABLE) |
| 168 | find_program(NETWORKCTL_EXECUTABLE networkctl) |
| 169 | endif() |
Václav Kubernát | 566c940 | 2021-02-10 08:33:54 +0100 | [diff] [blame] | 170 | if(NOT HOSTNAMECTL_EXECUTABLE) |
| 171 | find_program(HOSTNAMECTL_EXECUTABLE hostnamectl) |
| 172 | endif() |
Václav Kubernát | babbab9 | 2021-01-27 09:25:05 +0100 | [diff] [blame] | 173 | |
| 174 | set(VELIA_AUTHORIZED_KEYS_FORMAT "{HOME}/.ssh/authorized_keys" CACHE STRING "pattern for determining path to users' SSH authorized_keys file. Must at least one of '{USER}' or '{HOME}' which will get replaced by the name of the user and the home directory of the user respectively.") |
| 175 | if(NOT VELIA_AUTHORIZED_KEYS_FORMAT) |
| 176 | message(FATAL_ERROR "VELIA_AUTHORIZED_KEYS_FORMAT not set.") |
| 177 | endif() |
| 178 | |
| 179 | if(NOT VELIA_AUTHORIZED_KEYS_FORMAT MATCHES "{USER}" AND NOT VELIA_AUTHORIZED_KEYS_FORMAT MATCHES "{HOME}") |
| 180 | message(FATAL_ERROR "Wrong format string given for VELIA_AUTHORIZED_KEYS_FORMAT: at least one of {USER} or {HOME} expected.") |
| 181 | endif() |
| 182 | |
| 183 | set(VELIA_REAL_ETC_PASSWD "/etc/passwd" CACHE STRING "Path to passwd file") |
| 184 | if(NOT VELIA_REAL_ETC_PASSWD) |
| 185 | message(FATAL_ERROR "VELIA_REAL_ETC_PASSWD not set") |
| 186 | endif() |
| 187 | |
| 188 | set(VELIA_REAL_ETC_SHADOW "/etc/shadow" CACHE STRING "Path to shadow file") |
| 189 | if(NOT VELIA_REAL_ETC_SHADOW) |
| 190 | message(FATAL_ERROR "VELIA_REAL_ETC_SHADOW not set") |
| 191 | endif() |
| 192 | |
| 193 | set(VELIA_BACKUP_ETC_SHADOW "/etc/shadow" CACHE STRING "Path to where /etc/shadow gets copied to upon each change") |
| 194 | if(NOT VELIA_BACKUP_ETC_SHADOW) |
| 195 | message(FATAL_ERROR "VELIA_BACKUP_ETC_SHADOW not set") |
| 196 | endif() |
Václav Kubernát | de0e4e6 | 2021-02-08 17:46:14 +0100 | [diff] [blame] | 197 | |
Václav Kubernát | 566c940 | 2021-02-10 08:33:54 +0100 | [diff] [blame] | 198 | set(VELIA_BACKUP_ETC_HOSTNAME "/etc/hostname" CACHE STRING "Path to hostname file") |
| 199 | if(NOT VELIA_BACKUP_ETC_HOSTNAME ) |
| 200 | message(FATAL_ERROR "VELIA_BACKUP_ETC_HOSTNAME not set") |
| 201 | endif() |
| 202 | |
Václav Kubernát | 6d9357e | 2021-01-28 15:38:24 +0100 | [diff] [blame] | 203 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/system/system_vars.h.in ${CMAKE_CURRENT_BINARY_DIR}/system_vars.h @ONLY) |
| 204 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) |
| 205 | |
Tomáš Pecka | 292bc9c | 2021-01-11 22:03:11 +0100 | [diff] [blame] | 206 | # - ietf-system |
| 207 | add_library(velia-system STATIC |
Tomáš Pecka | 991e4d5 | 2021-01-11 10:03:14 +0100 | [diff] [blame] | 208 | src/system/RAUC.cpp |
| 209 | src/system/RAUC.h |
Tomáš Pecka | 594a676 | 2021-01-29 11:06:08 +0100 | [diff] [blame] | 210 | src/system/Firmware.cpp |
| 211 | src/system/Firmware.h |
Tomáš Pecka | f976c5b | 2021-01-23 21:19:52 +0100 | [diff] [blame] | 212 | src/system/IETFSystem.cpp |
| 213 | src/system/IETFSystem.h |
Václav Kubernát | babbab9 | 2021-01-27 09:25:05 +0100 | [diff] [blame] | 214 | src/system/Authentication.cpp |
| 215 | src/system/Authentication.h |
Tomáš Pecka | 2d578c8 | 2021-02-23 19:01:35 +0100 | [diff] [blame] | 216 | src/system/Rtnetlink.cpp |
| 217 | src/system/Rtnetlink.h |
Tomáš Pecka | f10b930 | 2021-02-23 19:02:02 +0100 | [diff] [blame] | 218 | src/system/IETFInterfaces.cpp |
| 219 | src/system/IETFInterfaces.h |
Tomáš Pecka | 39bbb51 | 2021-05-23 22:07:22 +0200 | [diff] [blame] | 220 | src/system/IETFInterfacesConfig.cpp |
| 221 | src/system/IETFInterfacesConfig.h |
Tomáš Pecka | af7b704 | 2021-04-20 20:14:13 +0200 | [diff] [blame] | 222 | src/system/LED.cpp |
| 223 | src/system/LED.h |
Tomáš Pecka | 7acf392 | 2021-08-10 11:16:57 +0200 | [diff] [blame] | 224 | src/system/LLDP.cpp |
| 225 | src/system/LLDP.h |
| 226 | src/system/LLDPCallback.cpp |
| 227 | src/system/LLDPCallback.h |
Tomáš Pecka | 292bc9c | 2021-01-11 22:03:11 +0100 | [diff] [blame] | 228 | ) |
| 229 | target_link_libraries(velia-system |
| 230 | PUBLIC |
| 231 | velia-utils |
| 232 | PkgConfig::SYSREPO |
| 233 | PkgConfig::LIBYANG |
Tomáš Pecka | 2d578c8 | 2021-02-23 19:01:35 +0100 | [diff] [blame] | 234 | PkgConfig::LIBNL |
Václav Kubernát | 6dd52c8 | 2021-01-21 08:38:42 +0100 | [diff] [blame] | 235 | SDBusCpp::sdbus-c++ |
Tomáš Pecka | 292bc9c | 2021-01-11 22:03:11 +0100 | [diff] [blame] | 236 | ) |
| 237 | |
Václav Kubernát | d386aba | 2021-01-19 10:03:28 +0100 | [diff] [blame] | 238 | # - firewall |
| 239 | add_library(velia-firewall STATIC |
| 240 | src/firewall/Firewall.cpp |
| 241 | ) |
| 242 | target_link_libraries(velia-firewall |
| 243 | PUBLIC |
| 244 | velia-utils |
| 245 | PkgConfig::SYSREPO |
| 246 | PRIVATE |
| 247 | PkgConfig::LIBYANG |
| 248 | ) |
| 249 | |
| 250 | |
Tomáš Pecka | 625b7a1 | 2021-01-23 20:55:51 +0100 | [diff] [blame] | 251 | # - daemons |
Tomáš Pecka | cd19e62 | 2021-01-27 09:18:11 +0100 | [diff] [blame] | 252 | add_executable(veliad-health |
| 253 | src/main-health.cpp |
Tomáš Pecka | 139e361 | 2021-01-25 19:49:00 +0100 | [diff] [blame] | 254 | src/health/Factory.cpp |
| 255 | src/health/Factory.h |
| 256 | ) |
Tomáš Pecka | cd19e62 | 2021-01-27 09:18:11 +0100 | [diff] [blame] | 257 | target_link_libraries(veliad-health |
Tomáš Pecka | aae9fe3 | 2021-01-25 19:57:22 +0100 | [diff] [blame] | 258 | PUBLIC |
Tomáš Pecka | d03044f | 2020-11-12 14:33:10 +0100 | [diff] [blame] | 259 | velia-health |
Tomáš Pecka | d03044f | 2020-11-12 14:33:10 +0100 | [diff] [blame] | 260 | docopt |
Tomáš Pecka | aae9fe3 | 2021-01-25 19:57:22 +0100 | [diff] [blame] | 261 | ) |
Tomáš Pecka | cd19e62 | 2021-01-27 09:18:11 +0100 | [diff] [blame] | 262 | add_dependencies(veliad-health target-VELIA_VERSION) |
| 263 | target_include_directories(veliad-health PUBLIC ${CMAKE_BINARY_DIR}) |
Tomáš Pecka | d03044f | 2020-11-12 14:33:10 +0100 | [diff] [blame] | 264 | |
Tomáš Pecka | 625b7a1 | 2021-01-23 20:55:51 +0100 | [diff] [blame] | 265 | add_executable(veliad-system |
| 266 | src/main-system.cpp |
| 267 | ) |
| 268 | target_link_libraries(veliad-system |
| 269 | PUBLIC |
| 270 | velia-system |
| 271 | docopt |
| 272 | ) |
| 273 | add_dependencies(veliad-system target-VELIA_VERSION) |
| 274 | target_include_directories(veliad-system PUBLIC ${CMAKE_BINARY_DIR}) |
| 275 | |
Václav Kubernát | d386aba | 2021-01-19 10:03:28 +0100 | [diff] [blame] | 276 | add_executable(veliad-firewall |
| 277 | src/main-firewall.cpp |
| 278 | ) |
| 279 | target_link_libraries(veliad-firewall |
| 280 | PUBLIC |
| 281 | velia-firewall |
| 282 | velia-utils |
Václav Kubernát | d386aba | 2021-01-19 10:03:28 +0100 | [diff] [blame] | 283 | docopt |
| 284 | ) |
| 285 | add_dependencies(veliad-firewall target-VELIA_VERSION) |
| 286 | target_include_directories(veliad-firewall PUBLIC ${CMAKE_BINARY_DIR}) |
| 287 | |
Tomáš Pecka | aae9fe3 | 2021-01-25 19:57:22 +0100 | [diff] [blame] | 288 | add_executable(veliad-hardware |
| 289 | src/main-hardware.cpp |
| 290 | src/ietf-hardware/Factory.cpp |
| 291 | src/ietf-hardware/Factory.h |
| 292 | ) |
| 293 | target_link_libraries(veliad-hardware |
| 294 | PUBLIC |
| 295 | velia-ietf-hardware |
| 296 | velia-ietf-hardware-sysrepo |
| 297 | docopt |
| 298 | ) |
| 299 | add_dependencies(veliad-hardware target-VELIA_VERSION) |
| 300 | target_include_directories(veliad-hardware PUBLIC ${CMAKE_BINARY_DIR}) |
| 301 | |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 302 | # Testing |
Tomáš Pecka | a06d74d | 2020-06-14 18:18:13 +0200 | [diff] [blame] | 303 | include(CTest) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 304 | if(BUILD_TESTING) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 305 | find_package(trompeloeil 33 REQUIRED) |
| 306 | find_package(doctest 2.3.1 REQUIRED) |
| 307 | |
Tomáš Pecka | 9fa5f6a | 2021-04-13 11:36:11 +0200 | [diff] [blame] | 308 | option(TEST_NETWORK_WITH_SUDO "Include ietf-routing and ietf-interfaces tests that require root privileges" "OFF") |
| 309 | |
Tomáš Pecka | efd8843 | 2020-06-17 15:31:39 +0200 | [diff] [blame] | 310 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tests/configure.cmake.h.in ${CMAKE_CURRENT_BINARY_DIR}/tests/configure.cmake.h) |
| 311 | |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 312 | add_library(DoctestIntegration STATIC |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 313 | tests/doctest_integration.cpp |
| 314 | tests/trompeloeil_doctest.h |
| 315 | tests/wait-a-bit-longer.cpp |
| 316 | ) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 317 | target_link_libraries(DoctestIntegration doctest::doctest trompeloeil spdlog::spdlog) |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 318 | target_include_directories(DoctestIntegration PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/tests/) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 319 | target_compile_definitions(DoctestIntegration PUBLIC DOCTEST_CONFIG_SUPER_FAST_ASSERTS) |
| 320 | |
Tomáš Pecka | a18702d | 2021-01-25 18:07:23 +0100 | [diff] [blame] | 321 | add_library(SysrepoTesting STATIC |
| 322 | tests/mock/sysrepo/events.cpp |
| 323 | tests/mock/sysrepo/events.h |
| 324 | ) |
| 325 | target_link_libraries(SysrepoTesting DoctestIntegration PkgConfig::SYSREPO) |
| 326 | |
Tomáš Pecka | 0a2e890 | 2020-06-09 21:11:20 +0200 | [diff] [blame] | 327 | add_library(DbusTesting STATIC |
Tomáš Pecka | 991e4d5 | 2021-01-11 10:03:14 +0100 | [diff] [blame] | 328 | tests/dbus-helpers/dbus_rauc_server.cpp |
| 329 | tests/dbus-helpers/dbus_rauc_server.h |
Tomáš Pecka | 79344c8 | 2021-09-16 18:25:59 +0200 | [diff] [blame] | 330 | tests/dbus-helpers/dbus_resolve1_server.cpp |
| 331 | tests/dbus-helpers/dbus_resolve1_server.h |
Tomáš Pecka | 0a2e890 | 2020-06-09 21:11:20 +0200 | [diff] [blame] | 332 | tests/dbus-helpers/dbus_semaphore_server.cpp |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 333 | tests/dbus-helpers/dbus_semaphore_server.h |
Tomáš Pecka | ccd80c3 | 2020-06-22 14:44:32 +0200 | [diff] [blame] | 334 | tests/dbus-helpers/dbus_systemd_server.cpp |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 335 | tests/dbus-helpers/dbus_systemd_server.h |
| 336 | ) |
| 337 | target_link_libraries(DbusTesting |
| 338 | PUBLIC |
| 339 | velia-utils |
| 340 | SDBusCpp::sdbus-c++ |
| 341 | ) |
Tomáš Pecka | 0a2e890 | 2020-06-09 21:11:20 +0200 | [diff] [blame] | 342 | |
Tomáš Pecka | 9b1c967 | 2020-11-11 15:24:06 +0100 | [diff] [blame] | 343 | add_library(FsTestUtils STATIC |
| 344 | tests/fs-helpers/FileInjector.cpp |
| 345 | tests/fs-helpers/FileInjector.h |
| 346 | tests/fs-helpers/utils.cpp |
| 347 | tests/fs-helpers/utils.h |
| 348 | ) |
| 349 | target_link_libraries(FsTestUtils |
| 350 | PUBLIC |
| 351 | ${STD_FILESYSTEM_LIBRARY} |
| 352 | ) |
| 353 | |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 354 | find_program(SYSREPOCTL sysrepoctl) |
| 355 | find_program(SYSREPOCFG sysrepocfg) |
| 356 | |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 357 | function(velia_test name) |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 358 | add_executable(test-${name} ${CMAKE_SOURCE_DIR}/tests/${name}.cpp) |
Václav Kubernát | 6677c22 | 2021-11-12 11:46:45 +0100 | [diff] [blame] | 359 | target_link_libraries(test-${name} DoctestIntegration) |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 360 | target_include_directories(test-${name} |
| 361 | PUBLIC |
| 362 | ${CMAKE_CURRENT_SOURCE_DIR} |
| 363 | PRIVATE |
| 364 | ${CMAKE_BINARY_DIR} |
| 365 | ) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 366 | |
| 367 | if(NOT CMAKE_CROSSCOMPILING) |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 368 | add_test(test-${name} test-${name}) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 369 | endif() |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 370 | |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 371 | set(test_name_init sysrepo:prep:${name}) |
| 372 | set(test_name_cleanup sysrepo:clean:${name}) |
| 373 | set(fixture_name sysrepo:env:${name}) |
| 374 | |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 375 | # How to do this: |
| 376 | # Check ARGN for name of fixture |
| 377 | # then take the args for manage module from variable "fixture{fixture_name}" |
| 378 | # and then add set env vars for sysrepo |
| 379 | # set them ALSO for the init/cleanup tests |
| 380 | if(ARGC GREATER 1) |
| 381 | set(wanted_fixture ${ARGV1}) |
| 382 | add_test(NAME ${test_name_init} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/sysrepoctl-manage-module.sh ${SYSREPOCTL} ${SYSREPOCFG} prepare ${${wanted_fixture}}) |
| 383 | set_tests_properties(${test_name_init} PROPERTIES FIXTURES_SETUP ${fixture_name}) |
| 384 | add_test(NAME ${test_name_cleanup} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/sysrepoctl-manage-module.sh ${SYSREPOCTL} ${SYSREPOCFG} uninstall ${${wanted_fixture}}) |
| 385 | set_tests_properties(${test_name_cleanup} PROPERTIES FIXTURES_CLEANUP ${fixture_name}) |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 386 | |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 387 | set_tests_properties(test-${name} PROPERTIES FIXTURES_REQUIRED ${fixture_name}) |
| 388 | set_property(TEST test-${name} ${test_name_init} ${test_name_cleanup} APPEND PROPERTY ENVIRONMENT |
| 389 | "SYSREPO_REPOSITORY_PATH=${CMAKE_CURRENT_BINARY_DIR}/test_repositories/test_${name}" |
| 390 | "SYSREPO_SHM_PREFIX=velia_test_${name}" |
| 391 | ) |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 392 | |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 393 | endif() |
| 394 | |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 395 | endfunction() |
| 396 | |
Václav Kubernát | 6677c22 | 2021-11-12 11:46:45 +0100 | [diff] [blame] | 397 | velia_test(health_state-manager) |
| 398 | target_link_libraries(test-health_state-manager velia-health) |
| 399 | velia_test(health_input-semaphore) |
| 400 | target_link_libraries(test-health_input-semaphore velia-health DbusTesting) |
| 401 | velia_test(health_input-systemd) |
| 402 | target_link_libraries(test-health_input-systemd velia-health DbusTesting) |
| 403 | velia_test(health_output-led) |
| 404 | target_link_libraries(test-health_output-led velia-health) |
Tomáš Pecka | 491f4f2 | 2020-11-05 15:44:00 +0100 | [diff] [blame] | 405 | |
Václav Kubernát | 6677c22 | 2021-11-12 11:46:45 +0100 | [diff] [blame] | 406 | velia_test(system_rauc) |
| 407 | target_link_libraries(test-system_rauc velia-system DbusTesting) |
Tomáš Pecka | cb7a5f8 | 2021-01-20 15:12:00 +0100 | [diff] [blame] | 408 | set_tests_properties( |
| 409 | test-system_rauc |
| 410 | PROPERTIES RESOURCE_LOCK dbus-rauc |
| 411 | ) |
Tomáš Pecka | 991e4d5 | 2021-01-11 10:03:14 +0100 | [diff] [blame] | 412 | |
Václav Kubernát | 6677c22 | 2021-11-12 11:46:45 +0100 | [diff] [blame] | 413 | velia_test(system_lldp) |
| 414 | target_link_libraries(test-system_lldp velia-system DbusTesting) |
Tomáš Pecka | 7acf392 | 2021-08-10 11:16:57 +0200 | [diff] [blame] | 415 | |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 416 | set(fixture_sysrepo-czechlight-lldp YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/czechlight-lldp@2020-11-04.yang) |
| 417 | velia_test(sysrepo_system-lldp fixture_sysrepo-czechlight-lldp) |
Václav Kubernát | 6677c22 | 2021-11-12 11:46:45 +0100 | [diff] [blame] | 418 | target_link_libraries(test-sysrepo_system-lldp velia-system DbusTesting) |
Tomáš Pecka | 7acf392 | 2021-08-10 11:16:57 +0200 | [diff] [blame] | 419 | |
Václav Kubernát | 6677c22 | 2021-11-12 11:46:45 +0100 | [diff] [blame] | 420 | velia_test(hardware_emmc) |
| 421 | target_link_libraries(test-hardware_emmc velia-ietf-hardware FsTestUtils) |
| 422 | velia_test(hardware_hwmon) |
| 423 | target_link_libraries(test-hardware_hwmon velia-ietf-hardware FsTestUtils) |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 424 | |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 425 | set(fixture_sysrepo-ietf-system YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/ietf-system@2014-08-06.yang) |
| 426 | velia_test(sysrepo_system-ietfsystem fixture_sysrepo-ietf-system) |
Václav Kubernát | 6677c22 | 2021-11-12 11:46:45 +0100 | [diff] [blame] | 427 | target_link_libraries(test-sysrepo_system-ietfsystem velia-system DbusTesting) |
Tomáš Pecka | cb7a5f8 | 2021-01-20 15:12:00 +0100 | [diff] [blame] | 428 | |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 429 | set(fixture_sysrepo-czechlight-system YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/czechlight-system@2021-01-13.yang) |
| 430 | velia_test(sysrepo_system-firmware fixture_sysrepo-czechlight-system) |
Václav Kubernát | 6677c22 | 2021-11-12 11:46:45 +0100 | [diff] [blame] | 431 | target_link_libraries(test-sysrepo_system-firmware velia-system DbusTesting SysrepoTesting) |
Tomáš Pecka | cb7a5f8 | 2021-01-20 15:12:00 +0100 | [diff] [blame] | 432 | set_tests_properties( |
Tomáš Pecka | 594a676 | 2021-01-29 11:06:08 +0100 | [diff] [blame] | 433 | test-sysrepo_system-firmware |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 434 | PROPERTIES RESOURCE_LOCK dbus-rauc |
Tomáš Pecka | 292bc9c | 2021-01-11 22:03:11 +0100 | [diff] [blame] | 435 | ) |
| 436 | |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 437 | velia_test(sysrepo_authentication fixture_sysrepo-czechlight-system) |
Václav Kubernát | 6677c22 | 2021-11-12 11:46:45 +0100 | [diff] [blame] | 438 | target_link_libraries(test-sysrepo_authentication velia-system FsTestUtils) |
Václav Kubernát | babbab9 | 2021-01-27 09:25:05 +0100 | [diff] [blame] | 439 | |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 440 | velia_test(sysrepo_system-leds fixture_sysrepo-czechlight-system) |
Václav Kubernát | 6677c22 | 2021-11-12 11:46:45 +0100 | [diff] [blame] | 441 | target_link_libraries(test-sysrepo_system-leds velia-system FsTestUtils) |
Tomáš Pecka | af7b704 | 2021-04-20 20:14:13 +0200 | [diff] [blame] | 442 | |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 443 | set(fixture_sysrepo-czechlight-network |
Tomáš Pecka | f10b930 | 2021-02-23 19:02:02 +0100 | [diff] [blame] | 444 | YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/iana-if-type@2017-01-19.yang |
| 445 | YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/ietf-interfaces@2018-02-20.yang |
| 446 | YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/ietf-ip@2018-02-22.yang |
Tomáš Pecka | 2a4ea7b | 2021-03-30 17:01:37 +0200 | [diff] [blame] | 447 | YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/ietf-routing@2018-03-13.yang |
| 448 | YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/ietf-ipv4-unicast-routing@2018-03-13.yang |
| 449 | YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/ietf-ipv6-unicast-routing@2018-03-13.yang |
Tomáš Pecka | f10b930 | 2021-02-23 19:02:02 +0100 | [diff] [blame] | 450 | YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/czechlight-network@2021-02-22.yang) |
Tomáš Pecka | 9fa5f6a | 2021-04-13 11:36:11 +0200 | [diff] [blame] | 451 | |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 452 | velia_test(sysrepo_system-ietfinterfaces fixture_sysrepo-czechlight-network) |
Václav Kubernát | 6677c22 | 2021-11-12 11:46:45 +0100 | [diff] [blame] | 453 | target_link_libraries(test-sysrepo_system-ietfinterfaces velia-system) |
Tomáš Pecka | f10b930 | 2021-02-23 19:02:02 +0100 | [diff] [blame] | 454 | |
Tomáš Pecka | 9fa5f6a | 2021-04-13 11:36:11 +0200 | [diff] [blame] | 455 | if(TEST_NETWORK_WITH_SUDO) |
| 456 | find_program(SUDO_EXECUTABLE sudo REQUIRED) |
| 457 | find_program(IPROUTE2_EXECUTABLE ip REQUIRED) |
| 458 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tests/test_vars.h.in ${CMAKE_CURRENT_BINARY_DIR}/test_vars.h @ONLY) |
| 459 | |
| 460 | add_test(NAME network-czechlight0-prepare COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/sysrepo_system-ietfinterfaces-sudo.sh ${SUDO_EXECUTABLE}) |
| 461 | add_test(NAME network-czechlight0-cleanup COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/sysrepo_system-ietfinterfaces-sudo.sh ${SUDO_EXECUTABLE}) |
| 462 | set_tests_properties(network-czechlight0-prepare PROPERTIES FIXTURES_SETUP network-czechlight0) |
| 463 | set_tests_properties(network-czechlight0-cleanup PROPERTIES FIXTURES_CLEANUP network-czechlight0) |
| 464 | |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 465 | velia_test(sysrepo_system-ietfinterfaces-sudo fixture_sysrepo-czechlight-network) |
Václav Kubernát | 6677c22 | 2021-11-12 11:46:45 +0100 | [diff] [blame] | 466 | target_link_libraries(test-sysrepo_system-ietfinterfaces-sudo velia-system) |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 467 | set_property(TEST test-sysrepo_system-ietfinterfaces-sudo APPEND PROPERTY FIXTURES_REQUIRED network-czechlight0) |
Tomáš Pecka | 9fa5f6a | 2021-04-13 11:36:11 +0200 | [diff] [blame] | 468 | endif() |
| 469 | |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 470 | set(fixture_sysrepo-ietf-hardware YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/iana-hardware@2018-03-13.yang YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/ietf-hardware@2018-03-13.yang FEATURE hardware-sensor) |
| 471 | velia_test(hardware_ietf-hardware fixture_sysrepo-ietf-hardware) |
Václav Kubernát | 6677c22 | 2021-11-12 11:46:45 +0100 | [diff] [blame] | 472 | target_link_libraries(test-hardware_ietf-hardware velia-ietf-hardware velia-ietf-hardware-sysrepo FsTestUtils) |
Tomáš Pecka | 55f64f8 | 2020-12-10 19:03:30 +0100 | [diff] [blame] | 473 | |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 474 | velia_test(sysrepo_two-daemons fixture_sysrepo-ietf-hardware) |
Václav Kubernát | 6677c22 | 2021-11-12 11:46:45 +0100 | [diff] [blame] | 475 | target_link_libraries(test-sysrepo_two-daemons velia-ietf-hardware-sysrepo) |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 476 | # ctest dance for sysrepo_two-daemons: compile daemon, create a fixture for test, add the test into the fixture |
Tomáš Pecka | 55f64f8 | 2020-12-10 19:03:30 +0100 | [diff] [blame] | 477 | add_executable(test-sysrepo_test_merge-daemon ${CMAKE_SOURCE_DIR}/tests/sysrepo_two-daemons_daemon.cpp) |
| 478 | target_link_libraries(test-sysrepo_test_merge-daemon PkgConfig::SYSREPO PkgConfig::LIBYANG) |
| 479 | |
| 480 | add_test(NAME sysrepo_test_merge-start COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/sysrepo_two-daemons_control.sh start) |
| 481 | add_test(NAME sysrepo_test_merge-stop COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/sysrepo_two-daemons_control.sh stop) |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 482 | set_tests_properties(sysrepo_test_merge-start PROPERTIES FIXTURES_SETUP sysrepo:two-daemons) |
| 483 | set_tests_properties(sysrepo_test_merge-stop PROPERTIES FIXTURES_CLEANUP sysrepo:two-daemons) |
| 484 | set_property(TEST sysrepo_test_merge-start sysrepo_test_merge-stop APPEND PROPERTY ENVIRONMENT |
| 485 | "SYSREPO_REPOSITORY_PATH=${CMAKE_CURRENT_BINARY_DIR}/test_repositories/test_sysrepo_two-daemons" |
| 486 | "SYSREPO_SHM_PREFIX=velia_test_sysrepo_two-daemons" |
| 487 | ) |
Tomáš Pecka | 55f64f8 | 2020-12-10 19:03:30 +0100 | [diff] [blame] | 488 | |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 489 | set_property(TEST test-sysrepo_two-daemons APPEND PROPERTY FIXTURES_REQUIRED sysrepo:two-daemons) |
| 490 | |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 491 | # ensure we run two-daemons merge test and ietf-hardware test sequentially and don't cleanup before everything ends |
| 492 | set_tests_properties(sysrepo_test_merge-start PROPERTIES DEPENDS test-hardware_ietf-hardware) |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 493 | set_tests_properties(sysrepo:clean:sysrepo_two-daemons PROPERTIES DEPENDS sysrepo_test_merge-stop) |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 494 | |
Tomáš Pecka | 73a13cc | 2020-11-17 11:12:19 +0100 | [diff] [blame] | 495 | |
| 496 | find_program(YANGLINT_PATH yanglint) |
| 497 | if (NOT YANGLINT_PATH) |
| 498 | message(FATAL_ERROR "Cannot find libyang's yanglint") |
| 499 | endif() |
| 500 | foreach(yang_file ${YANG_SRCS}) |
| 501 | add_test(NAME yang-tree:${yang_file} COMMAND ${YANGLINT_PATH} -f tree ${CMAKE_CURRENT_SOURCE_DIR}/${yang_file}) |
| 502 | endforeach() |
Václav Kubernát | d386aba | 2021-01-19 10:03:28 +0100 | [diff] [blame] | 503 | |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 504 | set(fixture_sysrepo-firewall |
Václav Kubernát | d386aba | 2021-01-19 10:03:28 +0100 | [diff] [blame] | 505 | # Installing czechlight-firewall automatically installs ietf-access-control-list as implemented (not just |
| 506 | # imported) but I still need to install it myself to enable the features. |
| 507 | YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/ietf-access-control-list@2019-03-04.yang |
Václav Kubernát | d386aba | 2021-01-19 10:03:28 +0100 | [diff] [blame] | 508 | FEATURE match-on-eth |
Václav Kubernát | 2b07363 | 2021-11-25 15:39:42 +0100 | [diff] [blame^] | 509 | FEATURE eth |
Václav Kubernát | d386aba | 2021-01-19 10:03:28 +0100 | [diff] [blame] | 510 | FEATURE match-on-ipv4 |
| 511 | FEATURE ipv4 |
| 512 | FEATURE match-on-ipv6 |
| 513 | FEATURE ipv6 |
| 514 | FEATURE mixed-eth-ipv4-ipv6 |
| 515 | YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/czechlight-firewall@2021-01-25.yang |
| 516 | ) |
| 517 | |
Václav Kubernát | 5a745d2 | 2021-11-12 12:09:57 +0100 | [diff] [blame] | 518 | velia_test(sysrepo-firewall fixture_sysrepo-firewall) |
Václav Kubernát | 6677c22 | 2021-11-12 11:46:45 +0100 | [diff] [blame] | 519 | target_link_libraries(test-sysrepo-firewall velia-firewall) |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 520 | endif() |
Tomáš Pecka | c927d66 | 2020-07-13 11:16:16 +0200 | [diff] [blame] | 521 | |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 522 | if(WITH_DOCS) |
| 523 | set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in) |
| 524 | set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) |
| 525 | configure_file(${doxyfile_in} ${doxyfile} @ONLY) |
| 526 | add_custom_target(doc |
| 527 | COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile} |
| 528 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
| 529 | COMMENT "Generating API documentation with Doxygen" |
| 530 | VERBATIM |
| 531 | SOURCES ${doxyfile_in} |
| 532 | ) |
Tomáš Pecka | a06d74d | 2020-06-14 18:18:13 +0200 | [diff] [blame] | 533 | endif() |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 534 | |
Tomáš Pecka | 73a13cc | 2020-11-17 11:12:19 +0100 | [diff] [blame] | 535 | set(YANG_DIR ${CMAKE_INSTALL_PREFIX}/share/velia/yang) |
| 536 | install(FILES ${YANG_SRCS} DESTINATION ${YANG_DIR}) |
Tomáš Pecka | eb31772 | 2021-04-13 21:33:20 +0200 | [diff] [blame] | 537 | install(FILES ${CMAKE_SOURCE_DIR}/yang/ietf-ipv6-router-advertisements@2018-03-13.yang DESTINATION ${YANG_DIR}) |
Tomáš Pecka | cd19e62 | 2021-01-27 09:18:11 +0100 | [diff] [blame] | 538 | install(TARGETS veliad-health RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/) |
Tomáš Pecka | 625b7a1 | 2021-01-23 20:55:51 +0100 | [diff] [blame] | 539 | install(TARGETS veliad-system RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/) |
Tomáš Pecka | aae9fe3 | 2021-01-25 19:57:22 +0100 | [diff] [blame] | 540 | install(TARGETS veliad-hardware RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/) |
Tomáš Pecka | fb14b18 | 2021-01-27 10:54:00 +0100 | [diff] [blame] | 541 | install(TARGETS veliad-firewall RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/) |