-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from nRF24/CMake-4-Linux
CMake for linux
- Loading branch information
Showing
37 changed files
with
2,607 additions
and
1,147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
name: Linux build | ||
|
||
on: | ||
pull_request: | ||
types: [opened, reopened] | ||
paths: | ||
- "*.h" | ||
- "*.cpp" | ||
- "CMakeLists.txt" | ||
- "cmake/**" | ||
- "examples/**.cpp" | ||
- "!**Makefile" # old build system is not tested in this workflow | ||
- ".github/workflows/build_linux.yml" | ||
push: | ||
paths: | ||
- "*.h" | ||
- "*.cpp" | ||
- "CMakeLists.txt" | ||
- "cmake/**" | ||
- "examples/**.cpp" | ||
- "!**Makefile" # old build system is not tested in this workflow | ||
- ".github/workflows/build_linux.yml" | ||
release: | ||
types: [published, edited] | ||
|
||
env: | ||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) | ||
BUILD_TYPE: Release | ||
|
||
jobs: | ||
using_cmake: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
|
||
matrix: | ||
toolchain: | ||
- compiler: "armhf" | ||
usr_dir: "arm-linux-gnueabihf" | ||
- compiler: "arm64" | ||
usr_dir: "aarch64-linux-gnu" | ||
# - compiler: "x86_64" | ||
# usr_dir: "x86_64-linux-gnux32" | ||
# - compiler: "i686" | ||
# usr_dir: "i686-linux-gnu" | ||
- compiler: "default" # github runner is hosted on a "amd64" | ||
usr_dir: "local" # use default compiler to test build all examples (including the ncurses ones) | ||
|
||
steps: | ||
# - name: provide toolchain (for x86_64) | ||
# if: ${{ matrix.toolchain.compiler == 'x86_64' }} | ||
# run: | | ||
# sudo apt-get update | ||
# sudo apt-get install gcc-x86-64-linux-gnux32 g++-x86-64-linux-gnux32 | ||
|
||
# - name: provide toolchain (for i686) | ||
# if: ${{ matrix.toolchain.compiler == 'i686' }} | ||
# run: | | ||
# sudo apt-get update | ||
# sudo apt-get install gcc-i686-linux-gnu g++-i686-linux-gnu | ||
|
||
- name: provide toolchain (for arm64) | ||
if: ${{ matrix.toolchain.compiler == 'arm64' }} | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | ||
- name: provide toolchain (for armhf) | ||
if: ${{ matrix.toolchain.compiler == 'armhf' }} | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf | ||
- name: checkout RF24 | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: nRF24/RF24 | ||
ref: rp2xxx | ||
|
||
- name: build & install RF24 | ||
run: | | ||
mkdir build | ||
cd build | ||
cmake .. -D CMAKE_BUILD_TYPE=$BUILD_TYPE -D RF24_DRIVER=SPIDEV \ | ||
-D CMAKE_INSTALL_PREFIX=/usr/${{ matrix.toolchain.usr_dir }} \ | ||
-D CMAKE_TOOLCHAIN_FILE=cmake/toolchains/${{ matrix.toolchain.compiler }}.cmake | ||
sudo make install | ||
- name: checkout RF24Network | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: nRF24/RF24Network | ||
|
||
- name: build & install RF24Network | ||
run: | | ||
mkdir build | ||
cd build | ||
cmake .. -D CMAKE_BUILD_TYPE=$BUILD_TYPE \ | ||
-D CMAKE_INSTALL_PREFIX=/usr/${{ matrix.toolchain.usr_dir }} \ | ||
-D CMAKE_TOOLCHAIN_FILE=cmake/toolchains/${{ matrix.toolchain.compiler }}.cmake | ||
sudo make install | ||
- name: checkout RF24Mesh | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: nRF24/RF24Mesh | ||
|
||
- name: build & install RF24Mesh | ||
run: | | ||
mkdir build | ||
cd build | ||
cmake .. -D CMAKE_BUILD_TYPE=$BUILD_TYPE \ | ||
-D CMAKE_INSTALL_PREFIX=/usr/${{ matrix.toolchain.usr_dir }} \ | ||
-D CMAKE_TOOLCHAIN_FILE=cmake/toolchains/${{ matrix.toolchain.compiler }}.cmake | ||
sudo make install | ||
- name: checkout RF24Gateway | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: create CMake build environment | ||
run: cmake -E make_directory ${{ github.workspace }}/build | ||
|
||
- name: configure lib | ||
working-directory: ${{ github.workspace }}/build | ||
run: | | ||
cmake .. -D CMAKE_BUILD_TYPE=$BUILD_TYPE \ | ||
-D CMAKE_INSTALL_PREFIX=/usr/${{ matrix.toolchain.usr_dir }} \ | ||
-D CMAKE_TOOLCHAIN_FILE=cmake/toolchains/${{ matrix.toolchain.compiler }}.cmake | ||
- name: build lib | ||
working-directory: ${{ github.workspace }}/build | ||
run: cmake --build . | ||
|
||
- name: install lib | ||
working-directory: ${{ github.workspace }}/build | ||
run: sudo cmake --install . | ||
|
||
- name: package lib | ||
working-directory: ${{ github.workspace }}/build | ||
run: sudo cpack | ||
|
||
- name: Save artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: "pkg_RF24Gateway" | ||
path: | | ||
${{ github.workspace }}/build/pkgs/*.deb | ||
${{ github.workspace }}/build/pkgs/*.rpm | ||
- name: Upload Release assets | ||
if: github.event_name == 'release' && (matrix.toolchain.compiler == 'armhf' || matrix.toolchain.compiler == 'arm64') | ||
uses: csexton/release-asset-action@master | ||
with: | ||
pattern: "${{ github.workspace }}/build/pkgs/librf24*" | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: clean build environment | ||
working-directory: ${{ github.workspace }}/build | ||
run: sudo rm -r ./* | ||
|
||
- name: configure examples | ||
working-directory: ${{ github.workspace }}/build | ||
run: | | ||
cmake ../examples \ | ||
-D CMAKE_TOOLCHAIN_FILE=../cmake/toolchains/${{ matrix.toolchain.compiler }}.cmake | ||
- name: build examples | ||
working-directory: ${{ github.workspace }}/build | ||
run: | | ||
cmake --build . | ||
file ./RF24GatewayNode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,64 @@ | ||
name: DoxyGen build | ||
name: build Docs | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
types: [opened, reopened] | ||
paths: | ||
- "*.h" | ||
- "*.md" | ||
- "docs/**" | ||
- "!**README.md" | ||
- "examples**.cpp" | ||
- ".github/workflows/doxygen.yml" | ||
- "Doxyfile" | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- "*.h" | ||
- "*.md" | ||
- "docs/**" | ||
- "!**README.md" | ||
- "examples**.cpp" | ||
- ".github/workflows/doxygen.yml" | ||
- "Doxyfile" | ||
release: | ||
branches: | ||
- master | ||
types: | ||
- published | ||
- edited | ||
branches: [master] | ||
types: [published, edited] | ||
|
||
jobs: | ||
build-doxygen: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: get latest release version number | ||
id: latest_ver | ||
uses: pozetroninc/github-action-get-latest-release@master | ||
with: | ||
repository: nRF24/RF24Gateway | ||
- name: checkout | ||
uses: actions/checkout@v2 | ||
- name: overwrite doxygen tags | ||
run: | | ||
touch doxygenAction | ||
echo "PROJECT_NUMBER = ${{ steps.latest_ver.outputs.release }}" >> doxygenAction | ||
echo "@INCLUDE = doxygenAction" >> Doxyfile | ||
- name: build doxygen | ||
uses: mattnotmitt/doxygen-action@v1 | ||
with: | ||
working-directory: '.' | ||
doxyfile-path: './Doxyfile' | ||
- name: upload to github pages | ||
if: ${{ github.event_name == 'release'}} | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./docs/html | ||
- name: get latest release version number | ||
id: latest_ver | ||
uses: pozetroninc/github-action-get-latest-release@master | ||
with: | ||
repository: nRF24/RF24Gateway | ||
|
||
- name: checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: overwrite doxygen tags | ||
run: | | ||
touch doxygenAction | ||
echo "PROJECT_NUMBER = ${{ steps.latest_ver.outputs.release }}" >> doxygenAction | ||
echo "@INCLUDE = doxygenAction" >> Doxyfile | ||
- name: build doxygen | ||
uses: mattnotmitt/doxygen-action@v1 | ||
with: | ||
working-directory: '.' | ||
doxyfile-path: './Doxyfile' | ||
|
||
- name: Save doxygen docs as artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: "RF24Gateway_doxygen_docs" | ||
path: ${{ github.workspace }}/docs/html | ||
|
||
- name: upload to github pages | ||
if: ${{ github.event_name == 'release'}} | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./docs/html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
# ignore doxygen generated files | ||
# Generated library files | ||
*.so | ||
*.so.1 | ||
|
||
# ignore docs folder | ||
docs/html/ | ||
docs/xml/ | ||
|
||
# ignore CMake stuff | ||
build/ | ||
*CMakeUserPresets.json | ||
|
||
# ignore local vscode folder | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
|
||
# Set the project name to your project name | ||
project(RF24Gateway C CXX) | ||
include(cmake/StandardProjectSettings.cmake) | ||
include(cmake/PreventInSourceBuilds.cmake) | ||
|
||
# Link this 'library' to set the c++ standard / compile-time options requested | ||
add_library(project_options INTERFACE) | ||
target_compile_features(project_options INTERFACE cxx_std_17) | ||
add_compile_options(-Ofast -Wall) | ||
|
||
# allow using CMake options to adjust RF24Network_config.h without modiying source code | ||
option(DEBUG_LEVEL "adjust the verbosity of the debugging messages" 0) | ||
|
||
# detect CPU and add compiler flags accordingly | ||
include(cmake/detectCPU.cmake) | ||
|
||
if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") | ||
option(ENABLE_BUILD_WITH_TIME_TRACE "Enable -ftime-trace to generate time tracing .json files on clang" OFF) | ||
if(ENABLE_BUILD_WITH_TIME_TRACE) | ||
add_compile_definitions(project_options INTERFACE -ftime-trace) | ||
endif() | ||
endif() | ||
|
||
# Link this 'library' to use the warnings specified in CompilerWarnings.cmake | ||
add_library(project_warnings INTERFACE) | ||
|
||
# enable cache system | ||
include(cmake/Cache.cmake) | ||
|
||
# standard compiler warnings | ||
include(cmake/CompilerWarnings.cmake) | ||
set_project_warnings(project_warnings) | ||
|
||
# get library info from Arduino IDE's required library.properties file | ||
include(cmake/GetLibInfo.cmake) # sets the variable LibTargetName | ||
|
||
# setup CPack options | ||
include(cmake/CPackInfo.cmake) | ||
|
||
find_library(RF24 rf24 REQUIRED) | ||
message(STATUS "using RF24 library: ${RF24}") | ||
|
||
find_library(RF24Network rf24network REQUIRED) | ||
message(STATUS "using RF24Network library: ${RF24Network}") | ||
|
||
find_library(RF24Mesh rf24mesh REQUIRED) | ||
message(STATUS "using RF24Mesh library: ${RF24Mesh}") | ||
|
||
########################### | ||
# create target for bulding the RF24Log lib | ||
########################### | ||
add_library(${LibTargetName} SHARED RF24Gateway.cpp) | ||
target_include_directories(${LibTargetName} PUBLIC ${CMAKE_CURRENT_LIST_DIR}) | ||
|
||
target_link_libraries(${LibTargetName} INTERFACE | ||
project_options | ||
project_warnings | ||
SHARED ${RF24} | ||
SHARED ${RF24Network} | ||
SHARED ${RF24Mesh} | ||
) | ||
|
||
set_target_properties( | ||
${LibTargetName} | ||
PROPERTIES | ||
SOVERSION ${${LibName}_VERSION_MAJOR} | ||
VERSION ${${LibName}_VERSION_STRING} | ||
) | ||
|
||
# assert the appropriate preprocessor macros for RF24Network_config.h | ||
if(DEBUG_LEVEL GREATER 0) | ||
message(STATUS "DEBUG_LEVEL set to ${DEBUG_LEVEL}") | ||
target_compile_definitions(${LibTargetName} PUBLIC DEBUG_LEVEL=${DEBUG_LEVEL}) | ||
endif() | ||
|
||
########################### | ||
# target install rules for the RF24Log lib | ||
########################### | ||
install(TARGETS ${LibTargetName} DESTINATION lib) | ||
|
||
install(FILES | ||
RF24Gateway.h | ||
DESTINATION include/RF24Gateway | ||
) | ||
|
||
# CMAKE_CROSSCOMPILING is only TRUE when CMAKE_TOOLCHAIN_FILE is specified via CLI | ||
if(CMAKE_HOST_UNIX AND "${CMAKE_CROSSCOMPILING}" STREQUAL "FALSE") | ||
install(CODE "message(STATUS \"Updating ldconfig\")") | ||
install(CODE "execute_process(COMMAND ldconfig)") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.