Skip to content

Commit 01ca0d1

Browse files
committed
Updated build for examples
1 parent a66c0f9 commit 01ca0d1

10 files changed

+93
-41
lines changed

.github/workflows/arm-linux.yml

+8-6
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,26 @@ jobs:
1717

1818
- name: Install packages
1919
working-directory: ./examples
20-
run: sudo apt-get update && ./toolchains/arm_install_packages.sh
20+
run: |
21+
sudo apt-get update
22+
./toolchains/arm_install_packages.sh
2123
2224
- name: Configure CMake
2325
working-directory: ./examples
24-
run: ./toolchains/arm_build.sh
26+
run: cmake . -B build --preset gcc-arm-simulator -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
2527

2628
- name: Build
2729
working-directory: ./examples
28-
run: ninja -C build-arm
30+
run: cmake --build build --config ${{env.BUILD_TYPE}}
2931

3032
- name: Run simple example
3133
working-directory: ./examples
32-
run: ./toolchains/arm_run.sh ./build-arm/run_simple
34+
run: ./toolchains/arm_run.sh ./build/run_simple
3335

3436
- name: Run punctured decoder example
3537
working-directory: ./examples
36-
run: ./toolchains/arm_run.sh ./build-arm/run_punctured_decoder
38+
run: ./toolchains/arm_run.sh ./build/run_punctured_decoder
3739

3840
- name: Run tests
3941
working-directory: ./examples
40-
run: ./toolchains/arm_run.sh ./build-arm/run_tests
42+
run: ./toolchains/arm_run.sh ./build/run_tests

.github/workflows/x86-linux.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ jobs:
2323
2424
- name: Configure CMake
2525
working-directory: ./examples
26-
run: cmake -B ./build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -G Ninja -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++
26+
run: cmake . -B build --preset gcc -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
2727

2828
- name: Build
2929
working-directory: ./examples
30-
run: ninja -C ./build
30+
run: cmake --build build --config ${{env.BUILD_TYPE}}
3131

3232
- name: Run simple example
3333
working-directory: ./examples

.github/workflows/x86-windows.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ jobs:
2121

2222
- name: Configure CMake
2323
working-directory: ./examples
24-
run: cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
24+
run: cmake . -B build --preset windows-msvc -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
2525

2626
- name: Build
2727
working-directory: ./examples
28-
run: ninja -C build
28+
run: cmake --build build --config ${{env.BUILD_TYPE}}
2929

3030
- name: Run simple example
3131
working-directory: ./examples

examples/.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ data/
88
venv/
99
.venv/
1010
.env/
11-
env/
11+
env/
12+
CMakeUserPresets.json

examples/CMakeLists.txt

-12
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,6 @@ function(create_example_target target)
1414
add_executable(${target} ${SRC_DIR}/${target}.cpp)
1515
target_include_directories(${target} PRIVATE ${SRC_DIR})
1616
target_compile_features(${target} PRIVATE cxx_std_17)
17-
if (NOT ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
18-
if(MSVC)
19-
# x86 processors
20-
target_compile_options(${target} PRIVATE /fp:fast /arch:AVX2 /W3)
21-
target_compile_definitions(${target} PRIVATE _CRT_SECURE_NO_WARNINGS)
22-
else()
23-
target_compile_options(${target} PRIVATE -march=native -ffast-math)
24-
endif()
25-
else()
26-
# arm processors
27-
target_compile_options(${target} PRIVATE -ffast-math)
28-
endif()
2917
target_link_libraries(${target} PRIVATE getopt viterbi)
3018
endfunction()
3119

examples/CMakePresets.json

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"version": 3,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 20,
6+
"patch": 0
7+
},
8+
"configurePresets": [
9+
{
10+
"name": "windows-msvc",
11+
"generator": "Ninja",
12+
"cacheVariables": {
13+
"CMAKE_C_COMPILER": "cl",
14+
"CMAKE_CXX_COMPILER": "cl",
15+
"CMAKE_CXX_FLAGS_INIT": "/MP /fp:fast /arch:AVX2 /D_CRT_SECURE_NO_WARNINGS /D_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING",
16+
"CMAKE_C_FLAGS_INIT": "/MP /fp:fast /arch:AVX2 /D_CRT_SECURE_NO_WARNINGS /D_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING"
17+
}
18+
},
19+
{
20+
"name": "windows-clang",
21+
"generator": "Ninja",
22+
"cacheVariables": {
23+
"CMAKE_C_COMPILER": "clang",
24+
"CMAKE_CXX_COMPILER": "clang++",
25+
"CMAKE_CXX_FLAGS_INIT": "-ffast-math -march=native -D_CRT_SECURE_NO_WARNINGS -D_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING",
26+
"CMAKE_C_FLAGS_INIT": "-ffast-math -march=native -D_CRT_SECURE_NO_WARNINGS -D_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING"
27+
}
28+
},
29+
{
30+
"name": "gcc",
31+
"generator": "Ninja",
32+
"cacheVariables": {
33+
"CMAKE_C_COMPILER": "gcc",
34+
"CMAKE_CXX_COMPILER": "g++",
35+
"CMAKE_CXX_FLAGS_INIT": "-ffast-math -march=native",
36+
"CMAKE_C_FLAGS_INIT": "-ffast-math -march=native"
37+
}
38+
},
39+
{
40+
"name": "clang",
41+
"generator": "Ninja",
42+
"cacheVariables": {
43+
"CMAKE_C_COMPILER": "clang",
44+
"CMAKE_CXX_COMPILER": "clang++",
45+
"CMAKE_CXX_FLAGS_INIT": "-ffast-math -march=native",
46+
"CMAKE_C_FLAGS_INIT": "-ffast-math -march=native"
47+
}
48+
},
49+
{
50+
"name": "clang-arm",
51+
"generator": "Ninja",
52+
"cacheVariables": {
53+
"CMAKE_C_COMPILER": "clang",
54+
"CMAKE_CXX_COMPILER": "clang++",
55+
"CMAKE_CXX_FLAGS_INIT": "-ffast-math",
56+
"CMAKE_C_FLAGS_INIT": "-ffast-math"
57+
}
58+
},
59+
{
60+
"name": "gcc-arm-simulator",
61+
"generator": "Ninja",
62+
"cacheVariables": {
63+
"CMAKE_C_COMPILER": "/usr/bin/aarch64-linux-gnu-gcc",
64+
"CMAKE_CXX_COMPILER": "/usr/bin/aarch64-linux-gnu-g++",
65+
"CMAKE_CXX_FLAGS_INIT": "-ffast-math",
66+
"CMAKE_C_FLAGS_INIT": "-ffast-math"
67+
}
68+
}
69+
]
70+
}

examples/README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ Example programs which use the viterbi decoder library.
33

44
## Building programs
55
1. ```cd examples```
6-
2. ```cmake . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release```
7-
3. ```ninja -C build```
6+
2. Configure cmake: ```cmake . -B build --preset windows-msvc -DCMAKE_BUILD_TYPE=Release```
7+
3. Build: ```cmake --build build --config Release```
8+
9+
Change preset for your specific compiler. Refer to ```CMakePresets.json``` for example presets.
810

911
## Programs
1012
| Name | Description |

examples/toolchains/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Files for setting up a aarch64 qemu emulator on ubuntu
44
Instructions taken from [here](https://azeria-labs.com/arm-on-x86-qemu-user/)
55

66
## Instructions
7-
1. <code>cd examples</code>
8-
2. <code>./toolchains/arm_install_packages.sh</code>
9-
3. <code>./toolchains/arm_build.sh</code>
10-
4. <code>ninja -C build-arm</code>
11-
5. <code>./toolchains/arm_run.sh ./build-arm/run_tests</code>
7+
1. ```cd examples```
8+
2. Install dependencies: ```./toolchains/arm_install_packages.sh```
9+
3. Configure cmake: ```cmake . -B build --preset gcc-arm-simulator -DCMAKE_BUILD_TYPE=Release```
10+
4. Build: ```cmake --build build --config Release```
11+
5. Run: ```./toolchains/arm_run.sh ./build/run_tests```

examples/toolchains/aarch64-linux-gnu.toolchain.cmake

-9
This file was deleted.

examples/toolchains/arm_build.sh

-2
This file was deleted.

0 commit comments

Comments
 (0)