Skip to content

Commit

Permalink
Updated build for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
williamyang98 committed Feb 15, 2024
1 parent a66c0f9 commit 01ca0d1
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 41 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/arm-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,26 @@ jobs:

- name: Install packages
working-directory: ./examples
run: sudo apt-get update && ./toolchains/arm_install_packages.sh
run: |
sudo apt-get update
./toolchains/arm_install_packages.sh
- name: Configure CMake
working-directory: ./examples
run: ./toolchains/arm_build.sh
run: cmake . -B build --preset gcc-arm-simulator -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build
working-directory: ./examples
run: ninja -C build-arm
run: cmake --build build --config ${{env.BUILD_TYPE}}

- name: Run simple example
working-directory: ./examples
run: ./toolchains/arm_run.sh ./build-arm/run_simple
run: ./toolchains/arm_run.sh ./build/run_simple

- name: Run punctured decoder example
working-directory: ./examples
run: ./toolchains/arm_run.sh ./build-arm/run_punctured_decoder
run: ./toolchains/arm_run.sh ./build/run_punctured_decoder

- name: Run tests
working-directory: ./examples
run: ./toolchains/arm_run.sh ./build-arm/run_tests
run: ./toolchains/arm_run.sh ./build/run_tests
4 changes: 2 additions & 2 deletions .github/workflows/x86-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ jobs:
- name: Configure CMake
working-directory: ./examples
run: cmake -B ./build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -G Ninja -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++
run: cmake . -B build --preset gcc -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

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

- name: Run simple example
working-directory: ./examples
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/x86-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:

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

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

- name: Run simple example
working-directory: ./examples
Expand Down
3 changes: 2 additions & 1 deletion examples/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ data/
venv/
.venv/
.env/
env/
env/
CMakeUserPresets.json
12 changes: 0 additions & 12 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@ function(create_example_target target)
add_executable(${target} ${SRC_DIR}/${target}.cpp)
target_include_directories(${target} PRIVATE ${SRC_DIR})
target_compile_features(${target} PRIVATE cxx_std_17)
if (NOT ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
if(MSVC)
# x86 processors
target_compile_options(${target} PRIVATE /fp:fast /arch:AVX2 /W3)
target_compile_definitions(${target} PRIVATE _CRT_SECURE_NO_WARNINGS)
else()
target_compile_options(${target} PRIVATE -march=native -ffast-math)
endif()
else()
# arm processors
target_compile_options(${target} PRIVATE -ffast-math)
endif()
target_link_libraries(${target} PRIVATE getopt viterbi)
endfunction()

Expand Down
70 changes: 70 additions & 0 deletions examples/CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 20,
"patch": 0
},
"configurePresets": [
{
"name": "windows-msvc",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_C_COMPILER": "cl",
"CMAKE_CXX_COMPILER": "cl",
"CMAKE_CXX_FLAGS_INIT": "/MP /fp:fast /arch:AVX2 /D_CRT_SECURE_NO_WARNINGS /D_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING",
"CMAKE_C_FLAGS_INIT": "/MP /fp:fast /arch:AVX2 /D_CRT_SECURE_NO_WARNINGS /D_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING"
}
},
{
"name": "windows-clang",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_CXX_FLAGS_INIT": "-ffast-math -march=native -D_CRT_SECURE_NO_WARNINGS -D_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING",
"CMAKE_C_FLAGS_INIT": "-ffast-math -march=native -D_CRT_SECURE_NO_WARNINGS -D_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING"
}
},
{
"name": "gcc",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++",
"CMAKE_CXX_FLAGS_INIT": "-ffast-math -march=native",
"CMAKE_C_FLAGS_INIT": "-ffast-math -march=native"
}
},
{
"name": "clang",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_CXX_FLAGS_INIT": "-ffast-math -march=native",
"CMAKE_C_FLAGS_INIT": "-ffast-math -march=native"
}
},
{
"name": "clang-arm",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_CXX_FLAGS_INIT": "-ffast-math",
"CMAKE_C_FLAGS_INIT": "-ffast-math"
}
},
{
"name": "gcc-arm-simulator",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_C_COMPILER": "/usr/bin/aarch64-linux-gnu-gcc",
"CMAKE_CXX_COMPILER": "/usr/bin/aarch64-linux-gnu-g++",
"CMAKE_CXX_FLAGS_INIT": "-ffast-math",
"CMAKE_C_FLAGS_INIT": "-ffast-math"
}
}
]
}
6 changes: 4 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ Example programs which use the viterbi decoder library.

## Building programs
1. ```cd examples```
2. ```cmake . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release```
3. ```ninja -C build```
2. Configure cmake: ```cmake . -B build --preset windows-msvc -DCMAKE_BUILD_TYPE=Release```
3. Build: ```cmake --build build --config Release```

Change preset for your specific compiler. Refer to ```CMakePresets.json``` for example presets.

## Programs
| Name | Description |
Expand Down
10 changes: 5 additions & 5 deletions examples/toolchains/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Files for setting up a aarch64 qemu emulator on ubuntu
Instructions taken from [here](https://azeria-labs.com/arm-on-x86-qemu-user/)

## Instructions
1. <code>cd examples</code>
2. <code>./toolchains/arm_install_packages.sh</code>
3. <code>./toolchains/arm_build.sh</code>
4. <code>ninja -C build-arm</code>
5. <code>./toolchains/arm_run.sh ./build-arm/run_tests</code>
1. ```cd examples```
2. Install dependencies: ```./toolchains/arm_install_packages.sh```
3. Configure cmake: ```cmake . -B build --preset gcc-arm-simulator -DCMAKE_BUILD_TYPE=Release```
4. Build: ```cmake --build build --config Release```
5. Run: ```./toolchains/arm_run.sh ./build/run_tests```
9 changes: 0 additions & 9 deletions examples/toolchains/aarch64-linux-gnu.toolchain.cmake

This file was deleted.

2 changes: 0 additions & 2 deletions examples/toolchains/arm_build.sh

This file was deleted.

0 comments on commit 01ca0d1

Please sign in to comment.