Skip to content

Commit ab3e85f

Browse files
Dorian Eikenbergrageagainsthepc
authored andcommitted
Add vcpkg integration
1 parent 7929d26 commit ab3e85f

39 files changed

+660
-334
lines changed

.editorconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ trim_trailing_whitespace = true
1111

1212
[*.y*ml]
1313
indent_size = 2
14-
indent_style = space
14+
15+
[*.json]
16+
indent_size = 2

.github/workflows/cpp-apitracing.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
image: gdatacyberdefense/clang-format:16
3737

3838
steps:
39-
- uses: actions/checkout@v3
39+
- uses: actions/checkout@v4
4040

4141
- name: Perform C++ format check
4242
run: find plugins/apitracing/ -iname *.h -o -iname *.cpp | xargs clang-format --style=file --dry-run --Werror
@@ -50,11 +50,20 @@ jobs:
5050
compiler: [ clang, gcc ]
5151

5252
steps:
53-
- uses: actions/checkout@v3
53+
- uses: actions/checkout@v4
54+
55+
- name: Export GitHub Actions cache environment variables
56+
uses: actions/github-script@v7
57+
with:
58+
script: |
59+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
60+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
5461
5562
- name: Build and test apitracing
5663
run: |
5764
cmake --preset ${{ matrix.compiler }}-debug
5865
cmake --build --preset ${{ matrix.compiler }}-build-debug
5966
ctest --preset ${{ matrix.compiler }}-test
6067
working-directory: plugins/apitracing
68+
env:
69+
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"

.github/workflows/cpp-core.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
image: gdatacyberdefense/clang-format:16
3333

3434
steps:
35-
- uses: actions/checkout@v3
35+
- uses: actions/checkout@v4
3636

3737
- name: Perform C++ format check
3838
run: find vmicore/ -iname *.h -o -iname *.cpp | xargs clang-format --style=file --dry-run --Werror
@@ -46,11 +46,20 @@ jobs:
4646
compiler: [clang, gcc]
4747

4848
steps:
49-
- uses: actions/checkout@v3
49+
- uses: actions/checkout@v4
50+
51+
- name: Export GitHub Actions cache environment variables
52+
uses: actions/github-script@v7
53+
with:
54+
script: |
55+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
56+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
5057
5158
- name: Build and test vmicore
5259
run: |
5360
cmake --preset ${{ matrix.compiler }}-debug
5461
cmake --build --preset ${{ matrix.compiler }}-build-debug
5562
ctest --preset ${{ matrix.compiler }}-test
5663
working-directory: vmicore
64+
env:
65+
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"

.github/workflows/cpp-inmemory.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
image: gdatacyberdefense/clang-format:16
3737

3838
steps:
39-
- uses: actions/checkout@v3
39+
- uses: actions/checkout@v4
4040

4141
- name: Perform C++ format check
4242
run: find plugins/inmemoryscanner/ -iname *.h -o -iname *.cpp | xargs clang-format --style=file --dry-run --Werror
@@ -50,11 +50,20 @@ jobs:
5050
compiler: [ clang, gcc ]
5151

5252
steps:
53-
- uses: actions/checkout@v3
53+
- uses: actions/checkout@v4
54+
55+
- name: Export GitHub Actions cache environment variables
56+
uses: actions/github-script@v7
57+
with:
58+
script: |
59+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
60+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
5461
5562
- name: Build and test inmemoryscanner
5663
run: |
5764
cmake --preset ${{ matrix.compiler }}-debug
5865
cmake --build --preset ${{ matrix.compiler }}-build-debug
5966
ctest --preset ${{ matrix.compiler }}-test
6067
working-directory: plugins/inmemoryscanner
68+
env:
69+
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"

.github/workflows/cpp-template.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
image: gdatacyberdefense/clang-format:16
3737

3838
steps:
39-
- uses: actions/checkout@v3
39+
- uses: actions/checkout@v4
4040

4141
- name: Perform C++ format check
4242
run: find plugins/template/ -iname *.h -o -iname *.cpp | xargs clang-format --style=file --dry-run --Werror
@@ -50,11 +50,20 @@ jobs:
5050
compiler: [ clang, gcc ]
5151

5252
steps:
53-
- uses: actions/checkout@v3
53+
- uses: actions/checkout@v4
54+
55+
- name: Export GitHub Actions cache environment variables
56+
uses: actions/github-script@v7
57+
with:
58+
script: |
59+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
60+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
5461
5562
- name: Build and test template
5663
run: |
5764
cmake --preset ${{ matrix.compiler }}-debug
5865
cmake --build --preset ${{ matrix.compiler }}-build-debug
5966
ctest --preset ${{ matrix.compiler }}-test
6067
working-directory: plugins/template
68+
env:
69+
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
Lines changed: 86 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,88 @@
11
{
2-
"version": 3,
3-
"configurePresets": [
4-
{
5-
"name": "clang-debug",
6-
"displayName": "Debug Clang",
7-
"description": "Use Clang toolchain",
8-
"generator": "Ninja",
9-
"binaryDir": "build-clang-debug/",
10-
"cacheVariables": {
11-
"CMAKE_BUILD_TYPE": "Debug",
12-
"CMAKE_C_COMPILER": "clang",
13-
"CMAKE_CXX_COMPILER": "clang++",
14-
"CMAKE_CXX_FLAGS": "-stdlib=libc++",
15-
"CMAKE_EXE_LINKER_FLAGS": "-fuse-ld=lld",
16-
"CMAKE_SHARED_LINKER_FLAGS": "-fuse-ld=lld"
17-
}
18-
},
19-
{
20-
"name": "gcc-debug",
21-
"displayName": "Debug G++",
22-
"description": "Use gcc toolchain",
23-
"generator": "Ninja",
24-
"binaryDir": "build-gcc-debug/",
25-
"cacheVariables": {
26-
"CMAKE_BUILD_TYPE": "Debug",
27-
"CMAKE_C_COMPILER": "gcc",
28-
"CMAKE_CXX_COMPILER": "g++"
29-
}
30-
}
31-
],
32-
"buildPresets": [
33-
{
34-
"name": "clang-build-debug",
35-
"displayName": "Build Clang Debug",
36-
"configurePreset": "clang-debug"
37-
},
38-
{
39-
"name": "gcc-build-debug",
40-
"displayName": "Build G++ Debug",
41-
"configurePreset": "gcc-debug"
42-
}
43-
],
44-
"testPresets": [
45-
{
46-
"name": "clang-test",
47-
"displayName": "Test Clang",
48-
"configurePreset": "clang-debug"
49-
},
50-
{
51-
"name": "gcc-test",
52-
"displayName": "Test G++",
53-
"configurePreset": "gcc-debug"
54-
}
55-
]
2+
"version": 3,
3+
"configurePresets": [
4+
{
5+
"name": "clang-debug",
6+
"displayName": "Clang Debug",
7+
"description": "Use Clang toolchain",
8+
"binaryDir": "build-clang-debug/",
9+
"generator": "Ninja",
10+
"cacheVariables": {
11+
"CMAKE_BUILD_TYPE": "Debug",
12+
"CMAKE_C_COMPILER": "clang",
13+
"CMAKE_CXX_COMPILER": "clang++",
14+
"CMAKE_CXX_FLAGS": "-stdlib=libc++",
15+
"CMAKE_EXE_LINKER_FLAGS": "-fuse-ld=lld",
16+
"CMAKE_SHARED_LINKER_FLAGS": "-fuse-ld=lld",
17+
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
18+
"VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/vcpkg/triplets/",
19+
"VCPKG_TARGET_TRIPLET": "x64-linux-clang"
20+
}
21+
},
22+
{
23+
"name": "clang-release",
24+
"displayName": "Clang Release",
25+
"inherits": "clang-debug",
26+
"binaryDir": "build-clang-release/",
27+
"cacheVariables": {
28+
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
29+
}
30+
},
31+
{
32+
"name": "gcc-debug",
33+
"displayName": "G++ Debug",
34+
"description": "Use gcc toolchain",
35+
"binaryDir": "build-gcc-debug/",
36+
"generator": "Ninja",
37+
"cacheVariables": {
38+
"CMAKE_BUILD_TYPE": "Debug",
39+
"CMAKE_C_COMPILER": "gcc",
40+
"CMAKE_CXX_COMPILER": "g++",
41+
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
42+
}
43+
},
44+
{
45+
"name": "gcc-release",
46+
"displayName": "G++ Release",
47+
"inherits": "gcc-debug",
48+
"binaryDir": "build-gcc-release/",
49+
"cacheVariables": {
50+
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
51+
}
52+
}
53+
],
54+
"buildPresets": [
55+
{
56+
"name": "clang-build-debug",
57+
"displayName": "Build Clang Debug",
58+
"configurePreset": "clang-debug"
59+
},
60+
{
61+
"name": "clang-build-release",
62+
"displayName": "Build Clang Release",
63+
"configurePreset": "clang-release"
64+
},
65+
{
66+
"name": "gcc-build-debug",
67+
"displayName": "Build G++ Debug",
68+
"configurePreset": "gcc-debug"
69+
},
70+
{
71+
"name": "gcc-build-release",
72+
"displayName": "Build G++ Release",
73+
"configurePreset": "gcc-release"
74+
}
75+
],
76+
"testPresets": [
77+
{
78+
"name": "clang-test",
79+
"displayName": "Test Clang",
80+
"configurePreset": "clang-debug"
81+
},
82+
{
83+
"name": "gcc-test",
84+
"displayName": "Test G++",
85+
"configurePreset": "gcc-debug"
86+
}
87+
]
5688
}

plugins/apitracing/Readme.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,17 @@ typedef struct _OBJECT_ATTRIBUTES {
167167
The parameter *ObjectName* is a pointer to a unicode and forms an exception since it is extracted directly.
168168
Both *PVOID* at the end are structs, that are currently not covered by our definitions.
169169
You can find a list under the struct section in the [function definitions file](configuration/functiondefinitions/functionDefinitions.yaml).
170+
171+
## How to Build
172+
173+
- Install Build Requirements
174+
- g++ or clang
175+
- cmake
176+
- vcpkg
177+
- Clone this repository
178+
- Inside the source directory, run:
179+
180+
```console
181+
[user@localhost source_dir]$ cmake --preset <gcc/clang>-debug
182+
[user@localhost source_dir]$ cmake --build --preset <gcc/clang>-build-debug
183+
```

plugins/apitracing/src/lib/CMakeLists.txt

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,48 +15,26 @@ target_compile_features(apitracing-obj PUBLIC cxx_std_20)
1515
set_target_properties(apitracing-obj PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
1616
target_include_directories(apitracing-obj INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
1717

18-
include(FindPkgConfig)
19-
pkg_check_modules(TCLAP REQUIRED tclap>=1.2)
18+
# Setup TClap
2019

21-
include(FetchContent)
20+
find_path(TCLAP_INCLUDE_DIRS "tclap/Arg.h")
21+
target_include_directories(apitracing-obj PUBLIC ${TCLAP_INCLUDE_DIRS})
2222

2323
# Setup fmt library as it is not available yet in gnu stdlib
2424

25-
FetchContent_Declare(
26-
fmt
27-
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
28-
GIT_TAG 8.1.1
29-
)
30-
FetchContent_MakeAvailable(fmt)
31-
target_link_libraries(apitracing-obj PUBLIC fmt-header-only)
25+
find_package(fmt CONFIG REQUIRED)
26+
target_link_libraries(apitracing-obj PUBLIC fmt::fmt)
3227

3328
# Setup yaml-cpp
3429

35-
FetchContent_Declare(
36-
yaml-cpp
37-
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
38-
GIT_TAG yaml-cpp-0.7.0
39-
)
40-
option(YAML_BUILD_SHARED_LIBS "" OFF)
41-
option(YAML_CPP_BUILD_TOOLS "" OFF)
42-
FetchContent_MakeAvailable(yaml-cpp)
43-
set_property(TARGET yaml-cpp PROPERTY POSITION_INDEPENDENT_CODE TRUE)
30+
find_package(yaml-cpp CONFIG REQUIRED)
31+
target_link_libraries(apitracing-obj PUBLIC yaml-cpp::yaml-cpp)
4432
target_compile_definitions(apitracing-obj PUBLIC YAML_CPP_SUPPORT)
45-
target_link_libraries(apitracing-obj PUBLIC yaml-cpp)
4633

4734
# Setup json-cpp
4835

49-
FetchContent_Declare(
50-
jsoncpp
51-
GIT_REPOSITORY https://github.com/open-source-parsers/jsoncpp.git
52-
GIT_TAG 1.9.5
53-
)
54-
option(JSONCPP_WITH_TESTS "" OFF)
55-
option(JSONCPP_WITH_POST_BUILD_UNITTEST "" OFF)
56-
option(JSONCPP_WITH_EXAMPLE "" OFF)
57-
FetchContent_MakeAvailable(jsoncpp)
58-
set_property(TARGET jsoncpp_static PROPERTY POSITION_INDEPENDENT_CODE TRUE)
59-
target_link_libraries(apitracing-obj PUBLIC jsoncpp_static)
36+
find_package(jsoncpp CONFIG REQUIRED)
37+
target_link_libraries(apitracing-obj PUBLIC JsonCpp::JsonCpp)
6038

6139
# Add public vmicore headers
6240

plugins/apitracing/test/CMakeLists.txt

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,17 @@ add_executable(apitracing-test
55
FunctionHook_UnitTest.cpp
66
TracedProcess_UnitTest.cpp
77
Tracer_UnitTest.cpp)
8-
target_link_libraries(apitracing-test apitracing-obj pthread)
8+
target_link_libraries(apitracing-test PRIVATE apitracing-obj)
99

1010
# Setup bundled google test framework
1111

12-
FetchContent_Declare(
13-
googletest
14-
GIT_REPOSITORY https://github.com/google/googletest.git
15-
GIT_TAG main
16-
)
17-
option(INSTALL_GTEST "" OFF)
18-
FetchContent_MakeAvailable(googletest)
19-
target_link_libraries(apitracing-test gtest gmock gmock_main)
12+
find_package(GTest CONFIG REQUIRED)
13+
target_link_libraries(apitracing-test PRIVATE GTest::gtest GTest::gmock GTest::gmock_main)
2014

2115
# Add VmiCore public test headers
2216

2317
add_subdirectory("${VMICORE_DIRECTORY_ROOT}/test/include" "${CMAKE_CURRENT_BINARY_DIR}/vmicore-public-test-headers")
24-
target_link_libraries(apitracing-test vmicore-public-test-headers)
18+
target_link_libraries(apitracing-test PRIVATE vmicore-public-test-headers)
2519

2620
# Copy config files to bin directory
2721

plugins/apitracing/vcpkg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../vcpkg/

0 commit comments

Comments
 (0)