Skip to content

Commit f698216

Browse files
Add addition CMake "run" targets to simplify calling exes (#344)
* Add addition CMake "run" targets to simplify calling exes * fix bad replace
1 parent e9cd684 commit f698216

File tree

8 files changed

+49
-30
lines changed

8 files changed

+49
-30
lines changed

.github/workflows/cmake.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ jobs:
2828
sudo make install
2929
3030
- name: test
31+
working-directory: tests/cmake
3132
run: |
32-
cd tests/cmake
3333
cmake . -DTEST:STRING="defaults-enabled" -DCMAKE_FIND_DEBUG_MODE=1
3434
cmake --build .
3535
@@ -43,12 +43,12 @@ jobs:
4343
run: |
4444
mkdir build
4545
cd build
46-
cmake ..
46+
cmake .. -DJWT_BUILD_EXAMPLES=ON
4747
sudo cmake --install .
4848
4949
- name: test
50+
working-directory: tests/cmake
5051
run: |
51-
cd tests/cmake
5252
cmake . -DTEST:STRING="defaults-enabled"
5353
cmake --build .
5454
@@ -114,6 +114,25 @@ jobs:
114114
cmake . -DCMAKE_PREFIX_PATH="/opt/jwt-cpp" -DTEST:STRING="defaults-enabled" -DCMAKE_FIND_DEBUG_MODE=1
115115
cmake --build .
116116
117+
root-hint-install-linux:
118+
runs-on: ubuntu-latest
119+
steps:
120+
- uses: actions/checkout@v3
121+
- uses: lukka/get-cmake@latest
122+
123+
- name: setup
124+
run: |
125+
mkdir build
126+
cd build
127+
cmake .. -DCMAKE_INSTALL_PREFIX:STRING="/opt/jwt-cpp" -DJWT_BUILD_EXAMPLES=OFF
128+
make install
129+
130+
- name: test
131+
run: |
132+
cd tests/cmake
133+
cmake . -Djwt-cpp_ROOT="/opt/jwt-cpp" -DTEST:STRING="defaults-enabled" -DCMAKE_FIND_DEBUG_MODE=1
134+
cmake --build .
135+
117136
custom-install-win:
118137
runs-on: windows-latest
119138
steps:
@@ -214,7 +233,7 @@ jobs:
214233
cmake . -DTEST:STRING="wolfssl-is-used"
215234
cmake --build .
216235
217-
with-hunter:
236+
with-hunter: # This is actually testing the integration with the package management
218237
runs-on: ubuntu-latest
219238
steps:
220239
- uses: actions/checkout@v4

.github/workflows/cross-platform.yml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,10 @@ jobs:
2929
shell: bash
3030
run: cmake --build .
3131

32-
- if: matrix.os != 'windows-latest'
33-
name: test
34-
working-directory: ${{ github.workspace }}/build
35-
shell: bash
36-
run: |
37-
./example/rsa-create
38-
./example/rsa-verify
39-
40-
- if: matrix.os == 'windows-latest'
41-
name: test
42-
working-directory: ${{ github.workspace }}/build
32+
- name: test
4333
run: |
44-
example\Debug\rsa-create.exe
45-
example\Debug\rsa-verify.exe
34+
cmake --build build/ --target rsa-create-run
35+
cmake --build build/ --target rsa-verify-run
4636
4737
- if: github.event_name == 'push' && always()
4838
uses: ./.github/actions/badge

.github/workflows/jwt.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@ jobs:
4747
cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DJWT_ENABLE_FUZZING=ON
4848
4949
- name: run
50-
working-directory: build
5150
run: |
52-
make jwt-cpp-fuzz-BaseEncodeFuzz jwt-cpp-fuzz-BaseDecodeFuzz jwt-cpp-fuzz-TokenDecodeFuzz
53-
./tests/fuzz/jwt-cpp-fuzz-BaseEncodeFuzz -runs=100000
54-
./tests/fuzz/jwt-cpp-fuzz-BaseDecodeFuzz -runs=100000 ../tests/fuzz/decode-corpus
55-
./tests/fuzz/jwt-cpp-fuzz-TokenDecodeFuzz -runs=100000 ../tests/fuzz/token-corpus
51+
cmake --build build/ --target jwt-cpp-fuzz-BaseEncodeFuzz-run
52+
cmake --build build/ --target jwt-cpp-fuzz-BaseDecodeFuzz-run
53+
cmake --build build/ --target jwt-cpp-fuzz-TokenDecodeFuzz-run
5654
5755
asan: # Based on https://gist.github.com/jlblancoc/44be9d4d466f0a973b1f3808a8e56782
5856
runs-on: ubuntu-latest

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Nuget CD
1+
name: Release CD
22

33
on:
44
# Allows you to run this workflow manually from the Actions tab

.github/workflows/targets.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
mkdir build
3838
cd build
3939
cmake ..
40+
cmake --build .
4041
cmake --install .
4142
- name: test
4243
working-directory: tests/cmake
@@ -45,6 +46,7 @@ jobs:
4546
cmake --build .
4647
4748
gcc-12:
49+
name: GCC 12
4850
runs-on: ubuntu-latest
4951
container:
5052
image: ubuntu:jammy-20231004 # 22.04
@@ -66,6 +68,7 @@ jobs:
6668
mkdir build
6769
cd build
6870
cmake ..
71+
cmake --build .
6972
cmake --install .
7073
7174
- name: test

example/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,22 @@ endif()
1313

1414
add_executable(print-claims print-claims.cpp)
1515
target_link_libraries(print-claims jwt-cpp::jwt-cpp)
16+
add_custom_target(print-claims-run COMMAND print-claims)
1617

1718
add_executable(private-claims private-claims.cpp)
1819
target_link_libraries(private-claims jwt-cpp::jwt-cpp)
1920

2021
add_executable(rsa-create rsa-create.cpp)
2122
target_link_libraries(rsa-create jwt-cpp::jwt-cpp)
23+
add_custom_target(rsa-create-run COMMAND rsa-create)
2224

2325
add_executable(rsa-verify rsa-verify.cpp)
2426
target_link_libraries(rsa-verify jwt-cpp::jwt-cpp)
27+
add_custom_target(rsa-verify-run COMMAND rsa-verify)
2528

2629
add_executable(jwks-verify jwks-verify.cpp)
2730
target_link_libraries(jwks-verify jwt-cpp::jwt-cpp)
31+
add_custom_target(jwks-verify-run COMMAND jwks-verify)
2832

2933
add_executable(es256k es256k.cpp)
3034
target_link_libraries(es256k jwt-cpp::jwt-cpp)

tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ target_link_libraries(jwt-cpp-test PRIVATE jwt-cpp nlohmann_json::nlohmann_json
7575
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:${CMAKE_DL_LIBS}>)
7676

7777
gtest_discover_tests(jwt-cpp-test)
78+
add_custom_target(jwt-cpp-test-run COMMAND jwt-cpp-test)
7879

7980
if(JWT_ENABLE_COVERAGE)
8081
include("code-coverage")

tests/fuzz/CMakeLists.txt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@ endif()
55
function(ADD_FUZZING_EXECUTABLE TARGET)
66
add_executable(jwt-cpp-fuzz-${TARGET} "${TARGET}.cpp")
77
target_compile_options(
8-
jwt-cpp-fuzz-${TARGET}
9-
PRIVATE -g -O1 -fsanitize=fuzzer,address,signed-integer-overflow,undefined
10-
-fno-omit-frame-pointer)
11-
target_link_options(
12-
jwt-cpp-fuzz-${TARGET} PRIVATE
13-
-fsanitize=fuzzer,address,signed-integer-overflow,undefined
14-
-fno-omit-frame-pointer)
8+
jwt-cpp-fuzz-${TARGET} PRIVATE -g -O1 -fsanitize=fuzzer,address,signed-integer-overflow,undefined
9+
-fno-omit-frame-pointer)
10+
target_link_options(jwt-cpp-fuzz-${TARGET} PRIVATE -fsanitize=fuzzer,address,signed-integer-overflow,undefined
11+
-fno-omit-frame-pointer)
1512
target_link_libraries(jwt-cpp-fuzz-${TARGET} PRIVATE jwt-cpp::jwt-cpp)
1613
endfunction()
1714

1815
add_fuzzing_executable(BaseEncodeFuzz)
16+
add_custom_target(jwt-cpp-fuzz-BaseEncodeFuzz-run COMMAND jwt-cpp-fuzz-BaseEncodeFuzz -runs=100000)
17+
1918
add_fuzzing_executable(BaseDecodeFuzz)
19+
add_custom_target(jwt-cpp-fuzz-BaseDecodeFuzz-run COMMAND jwt-cpp-fuzz-BaseDecodeFuzz -runs=100000 decode-corpus
20+
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
21+
2022
add_fuzzing_executable(TokenDecodeFuzz)
23+
add_custom_target(jwt-cpp-fuzz-TokenDecodeFuzz-run COMMAND jwt-cpp-fuzz-TokenDecodeFuzz -runs=100000 token-corpus
24+
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})

0 commit comments

Comments
 (0)