Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

add .deb example #1

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -24,17 +24,15 @@ jobs:
run: apt-get update && ./apt-setup.sh
- name: latest cmake
run: |
cd ~
ARCH=$(uname -m)
wget --quiet https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-$ARCH.sh
chmod +x cmake-${CMAKE_VERSION}-linux-$ARCH.sh
cd /usr
~/cmake-${CMAKE_VERSION}-linux-$ARCH.sh --skip-license
./cmake-${CMAKE_VERSION}-linux-$ARCH.sh --skip-license --prefix=/usr
- name: build
run: |
cmake --version
mkdir build && cd build
cmake .. -G Ninja
cmake -DFETCH_GIT=ON .. -G Ninja
ninja module-example-cpp
cd ..
- name: inspect output
48 changes: 48 additions & 0 deletions .github/workflows/debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
on:
push:

env:
CMAKE_VERSION: 3.27.4
VERSION: ${{ github.event_name == 'release' && github.ref_name || format('0.0.0-{0}.{1}', github.ref_name, github.run_number) }}

jobs:
build:
strategy:
matrix:
include:
- runs-on: buildjet-4vcpu-ubuntu-2204
arch: amd64
- runs-on: buildjet-4vcpu-ubuntu-2204-arm
arch: arm64
runs-on: ${{ matrix.runs-on }}
container: debian:bookworm
steps:
- uses: actions/checkout@v3
- name: deps
run: |
apt-get update
apt-get install -qy build-essential pkg-config ninja-build git wget libboost-log-dev file
- name: latest cmake
run: |
ARCH=$(uname -m)
wget --quiet https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-$ARCH.sh
chmod +x cmake-${CMAKE_VERSION}-linux-$ARCH.sh
./cmake-${CMAKE_VERSION}-linux-$ARCH.sh --skip-license --prefix=/usr
- name: install viam sdk
run: |
wget https://storage.googleapis.com/packages.viam.com/debian/cpp-sdk/viam-cpp-sdk-0.0.0-bookworm-`uname -m`.deb
apt-get install -qy ./viam-cpp-sdk-0.0.0-bookworm-`uname -m`.deb
- name: mkdir
run: mkdir build
- name: build
working-directory: build
run: |
cmake --version
cmake .. -G Ninja
ninja module-example-cpp
file module-example-cpp
ldd module-example-cpp
- uses: actions/upload-artifact@v3
with:
name: binary-${{ matrix.arch }}
path: build/module-example-cpp
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build/
*.tar.gz
*.deb
35 changes: 23 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -2,19 +2,30 @@ cmake_minimum_required(VERSION 3.7 FATAL_ERROR)

project(module-example-cpp LANGUAGES CXX)

option(FETCH_GIT "fetch from git instead of using debian package")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

include(FetchContent)
FetchContent_Declare(
viam-cpp-sdk
GIT_REPOSITORY https://github.com/viamrobotics/viam-cpp-sdk.git
GIT_TAG main
# SOURCE_DIR ${CMAKE_SOURCE_DIR}/../viam-cpp-sdk
CMAKE_ARGS -DVIAMCPPSDK_USE_DYNAMIC_PROTOS=ON
FIND_PACKAGE_ARGS
)
FetchContent_MakeAvailable(viam-cpp-sdk)

FILE(GLOB sources src/*.cpp)
add_executable(module-example-cpp ${sources})
target_link_libraries(module-example-cpp PRIVATE viam-cpp-sdk::viamsdk)

if (FETCH_GIT)
include(FetchContent)
FetchContent_Declare(
viam-cpp-sdk
GIT_REPOSITORY https://github.com/viamrobotics/viam-cpp-sdk.git
GIT_TAG main
# SOURCE_DIR ${CMAKE_SOURCE_DIR}/../viam-cpp-sdk
CMAKE_ARGS -DVIAMCPPSDK_USE_DYNAMIC_PROTOS=ON
FIND_PACKAGE_ARGS
)
FetchContent_MakeAvailable(viam-cpp-sdk)

target_link_libraries(module-example-cpp PRIVATE viam-cpp-sdk::viamsdk)
else()
find_package(PkgConfig REQUIRED)
pkg_search_module(VIAMSDK REQUIRED IMPORTED_TARGET viam-cpp-sdk-libviamsdk)
pkg_search_module(VIAMAPI REQUIRED IMPORTED_TARGET viam-cpp-sdk-libviamapi)

target_include_directories(module-example-cpp PRIVATE PkgConfig::VIAMSDK PkgConfig::VIAMAPI)
target_link_libraries(module-example-cpp PRIVATE PkgConfig::VIAMSDK PkgConfig::VIAMAPI)
endif()