diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 69579acea..298de21f9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,7 +29,12 @@ jobs: - name: Install dependencies run: | sudo apt-get update - sudo apt install libboost-dev libboost-filesystem-dev libboost-program-options-dev libyaml-cpp-dev valgrind + sudo apt install libboost-dev libboost-filesystem-dev libboost-program-options-dev + + - name: Install test dependencies + if: ${{matrix.target == 'tests'}} + run: | + sudo apt install libyaml-cpp-dev valgrind - uses: actions/checkout@v4 with: diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f3a497b6..674f149c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,9 @@ endif () if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - find_package(yaml-cpp REQUIRED) + if (VERIFIER_ENABLE_TESTS) + find_package(yaml-cpp REQUIRED) + endif() find_package(Boost REQUIRED) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -57,22 +59,24 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") set(Boost_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/packages/boost/lib/native/include) set(Boost_LIBRARY_DIRS ${CMAKE_BINARY_DIR}/packages/boost_filesystem-vc143/lib/native) - # MSVC's "std:c++20" option is the current standard that supports all the C++17 - # features we use. However, cmake can't deal with that here, so we set it below. - - set(EXTERNAL_INSTALL_LOCATION ${CMAKE_BINARY_DIR}/packages/yaml-cpp) - include(ExternalProject) - ExternalProject_Add(yaml-cpp - GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git - GIT_TAG "yaml-cpp-0.7.0" - GIT_SHALLOW true - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION} - -DYAML_MSVC_SHARED_RT=ON - -DYAML_CPP_BUILD_TESTS=OFF - -DYAML_CPP_BUILD_TOOLS=OFF - ) - set(YAML_CPP_LIBRARIES ${EXTERNAL_INSTALL_LOCATION}/lib/yaml-cpp$<$:d>.lib) - set(YAML_CPP_INCLUDE_DIR ${EXTERNAL_INSTALL_LOCATION}/include/) + if (VERIFIER_ENABLE_TESTS) + # MSVC's "std:c++20" option is the current standard that supports all the C++17 + # features we use. However, cmake can't deal with that here, so we set it below. + + set(EXTERNAL_INSTALL_LOCATION ${CMAKE_BINARY_DIR}/packages/yaml-cpp) + include(ExternalProject) + ExternalProject_Add(yaml-cpp + GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git + GIT_TAG "yaml-cpp-0.7.0" + GIT_SHALLOW true + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION} + -DYAML_MSVC_SHARED_RT=ON + -DYAML_CPP_BUILD_TESTS=OFF + -DYAML_CPP_BUILD_TOOLS=OFF + ) + set(YAML_CPP_LIBRARIES ${EXTERNAL_INSTALL_LOCATION}/lib/yaml-cpp$<$:d>.lib) + set(YAML_CPP_INCLUDE_DIR ${EXTERNAL_INSTALL_LOCATION}/include/) + endif() endif () include_directories(./external) @@ -97,6 +101,8 @@ file(GLOB LIB_SRC if(VERIFIER_ENABLE_TESTS) file(GLOB ALL_TEST + "src/test/ebpf_yaml.hpp" + "src/test/ebpf_yaml.hpp" "./src/test/test_conformance.cpp" "./src/test/test_marshal.cpp" "./src/test/test_print.cpp" diff --git a/src/ebpf_yaml.cpp b/src/test/ebpf_yaml.cpp similarity index 100% rename from src/ebpf_yaml.cpp rename to src/test/ebpf_yaml.cpp diff --git a/src/ebpf_yaml.hpp b/src/test/ebpf_yaml.hpp similarity index 100% rename from src/ebpf_yaml.hpp rename to src/test/ebpf_yaml.hpp