Skip to content

Commit

Permalink
upgrade conan (#20)
Browse files Browse the repository at this point in the history
* fix build error

* Upgrade conan

* Fix build

* Check versions

* Fix case

* Use conan to install

---------

Co-authored-by: rawia.moalla <rawia.moalla}technica-engineering.de>
  • Loading branch information
kayoub5 authored Jul 9, 2024
1 parent 3a4106d commit f5dc8df
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 31 deletions.
18 changes: 8 additions & 10 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,21 @@ jobs:
include:
- os: windows-latest
- os: ubuntu-latest
- os: macos-11
- os: macos-12

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- run: pip3 install wheel conan==1.61.0
- run: |
pip3 install wheel conan==2.5.0
conan --version
cmake --version
- name: Create Build Environment
run: cmake -E make_directory build

- name: Configure CMake
working-directory: build
run: cmake .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Create conan profile
run: conan profile detect

- name: Build
working-directory: build
run: cmake --build . --config ${{env.BUILD_TYPE}}
run: conan build . --build missing -s:a=build_type=${{env.BUILD_TYPE}}

- name: Test
working-directory: build
Expand Down
30 changes: 11 additions & 19 deletions apps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
cmake_minimum_required(VERSION 3.9)

list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_BINARY_DIR})

if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/conan.cmake")
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/0.18.1/conan.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/conan.cmake")
endif()

include(${CMAKE_CURRENT_BINARY_DIR}/conan.cmake)

conan_cmake_run(
REQUIRES pcapplusplus/22.05
GENERATORS CMakeDeps
BUILD missing
)
cmake_minimum_required(VERSION 3.17)

add_executable(tecmp_app "app.cpp")
find_package(pcapplusplus REQUIRED CONFIG)
find_package(PcapPlusPlus REQUIRED)

target_link_libraries(tecmp_app PRIVATE tecmp_library pcapplusplus::pcapplusplus)
target_compile_features(tecmp_app PRIVATE cxx_std_17)
target_link_libraries(tecmp_app PUBLIC tecmp_library PcapPlusPlus::PcapPlusPlus)
target_compile_features(tecmp_app PUBLIC cxx_std_17)

add_test(
NAME "tecmp_app.test"
COMMAND tecmp_app
"${CMAKE_CURRENT_LIST_DIR}/../traces/input_eth.pcap"
"${CMAKE_CURRENT_LIST_DIR}/../traces/output_eth.pcap"
)

install(
TARGETS tecmp_app DESTINATION "."
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)
4 changes: 2 additions & 2 deletions apps/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <unordered_map>
#include <errno.h>
#include <tecmp/tecmp.h>
#include "PcapFileDevice.h"
#include "pcapplusplus/PcapFileDevice.h"
#include <time.h>

using namespace pcpp;
Expand Down Expand Up @@ -86,7 +86,7 @@ int main(int argc, char* argv[]) {
res = tecmp_next(p.getRawData(), p.getRawDataLen(), &iterator, &header, &data);
}
}

}
reader->close();
writer.close();

Expand Down
46 changes: 46 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps


class TecmpAppRecipe(ConanFile):
name = "tecmp_app"
version = "0.1"
package_type = "application"

# Optional metadata
license = "<Put the package license here>"
author = "<Put your name here> <And your email here>"
url = "<Package recipe repository url here, for issues about the package>"
description = "<Description of tecmp_app package here>"
topics = ("<Put some tag here>", "<here>", "<and here>")

# Binary configuration
settings = "os", "compiler", "build_type", "arch"

# Sources are located in the same place as this recipe, copy them to the recipe
exports_sources = "CMakeLists.txt", "src/*"

package_folder = "../dist"

def requirements(self):
self.requires("pcapplusplus/23.09")

def layout(self):
cmake_layout(self)

def generate(self):
deps = CMakeDeps(self)
deps.generate()
tc = CMakeToolchain(self)
tc.generate()

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
cmake.install()

def package(self):
cmake = CMake(self)
cmake.install()

0 comments on commit f5dc8df

Please sign in to comment.