Skip to content

Commit f5dc8df

Browse files
authored
upgrade conan (#20)
* 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>
1 parent 3a4106d commit f5dc8df

File tree

4 files changed

+67
-31
lines changed

4 files changed

+67
-31
lines changed

.github/workflows/cmake.yml

+8-10
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,21 @@ jobs:
1515
include:
1616
- os: windows-latest
1717
- os: ubuntu-latest
18-
- os: macos-11
18+
- os: macos-12
1919

2020
steps:
2121
- uses: actions/checkout@v4
2222
- uses: actions/setup-python@v4
23-
- run: pip3 install wheel conan==1.61.0
23+
- run: |
24+
pip3 install wheel conan==2.5.0
25+
conan --version
26+
cmake --version
2427
25-
- name: Create Build Environment
26-
run: cmake -E make_directory build
27-
28-
- name: Configure CMake
29-
working-directory: build
30-
run: cmake .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
28+
- name: Create conan profile
29+
run: conan profile detect
3130

3231
- name: Build
33-
working-directory: build
34-
run: cmake --build . --config ${{env.BUILD_TYPE}}
32+
run: conan build . --build missing -s:a=build_type=${{env.BUILD_TYPE}}
3533

3634
- name: Test
3735
working-directory: build

apps/CMakeLists.txt

+11-19
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
1-
cmake_minimum_required(VERSION 3.9)
2-
3-
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_BINARY_DIR})
4-
5-
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/conan.cmake")
6-
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/0.18.1/conan.cmake"
7-
"${CMAKE_CURRENT_BINARY_DIR}/conan.cmake")
8-
endif()
9-
10-
include(${CMAKE_CURRENT_BINARY_DIR}/conan.cmake)
11-
12-
conan_cmake_run(
13-
REQUIRES pcapplusplus/22.05
14-
GENERATORS CMakeDeps
15-
BUILD missing
16-
)
1+
cmake_minimum_required(VERSION 3.17)
172

183
add_executable(tecmp_app "app.cpp")
19-
find_package(pcapplusplus REQUIRED CONFIG)
4+
find_package(PcapPlusPlus REQUIRED)
205

21-
target_link_libraries(tecmp_app PRIVATE tecmp_library pcapplusplus::pcapplusplus)
22-
target_compile_features(tecmp_app PRIVATE cxx_std_17)
6+
target_link_libraries(tecmp_app PUBLIC tecmp_library PcapPlusPlus::PcapPlusPlus)
7+
target_compile_features(tecmp_app PUBLIC cxx_std_17)
238

249
add_test(
2510
NAME "tecmp_app.test"
2611
COMMAND tecmp_app
2712
"${CMAKE_CURRENT_LIST_DIR}/../traces/input_eth.pcap"
2813
"${CMAKE_CURRENT_LIST_DIR}/../traces/output_eth.pcap"
2914
)
15+
16+
install(
17+
TARGETS tecmp_app DESTINATION "."
18+
RUNTIME DESTINATION bin
19+
ARCHIVE DESTINATION lib
20+
LIBRARY DESTINATION lib
21+
)

apps/app.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <unordered_map>
77
#include <errno.h>
88
#include <tecmp/tecmp.h>
9-
#include "PcapFileDevice.h"
9+
#include "pcapplusplus/PcapFileDevice.h"
1010
#include <time.h>
1111

1212
using namespace pcpp;
@@ -86,7 +86,7 @@ int main(int argc, char* argv[]) {
8686
res = tecmp_next(p.getRawData(), p.getRawDataLen(), &iterator, &header, &data);
8787
}
8888
}
89-
89+
}
9090
reader->close();
9191
writer.close();
9292

conanfile.py

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from conan import ConanFile
2+
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
3+
4+
5+
class TecmpAppRecipe(ConanFile):
6+
name = "tecmp_app"
7+
version = "0.1"
8+
package_type = "application"
9+
10+
# Optional metadata
11+
license = "<Put the package license here>"
12+
author = "<Put your name here> <And your email here>"
13+
url = "<Package recipe repository url here, for issues about the package>"
14+
description = "<Description of tecmp_app package here>"
15+
topics = ("<Put some tag here>", "<here>", "<and here>")
16+
17+
# Binary configuration
18+
settings = "os", "compiler", "build_type", "arch"
19+
20+
# Sources are located in the same place as this recipe, copy them to the recipe
21+
exports_sources = "CMakeLists.txt", "src/*"
22+
23+
package_folder = "../dist"
24+
25+
def requirements(self):
26+
self.requires("pcapplusplus/23.09")
27+
28+
def layout(self):
29+
cmake_layout(self)
30+
31+
def generate(self):
32+
deps = CMakeDeps(self)
33+
deps.generate()
34+
tc = CMakeToolchain(self)
35+
tc.generate()
36+
37+
def build(self):
38+
cmake = CMake(self)
39+
cmake.configure()
40+
cmake.build()
41+
cmake.install()
42+
43+
def package(self):
44+
cmake = CMake(self)
45+
cmake.install()
46+

0 commit comments

Comments
 (0)