Skip to content

Commit

Permalink
fix z_ping example;
Browse files Browse the repository at this point in the history
add option to treat compile warnings as errors;
  • Loading branch information
DenisBiryukov91 committed Oct 22, 2024
1 parent 4be991d commit 43f93c9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
shell: bash
run: |
mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/local -DZENOHC_BUILD_WITH_SHARED_MEMORY=${{ matrix.shm }} -DZENOHC_BUILD_WITH_UNSTABLE_API=${{ matrix.unstable }}
cmake .. -DZENOHC_TREAT_WARNING_AS_ERROR=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/local -DZENOHC_BUILD_WITH_SHARED_MEMORY=${{ matrix.shm }} -DZENOHC_BUILD_WITH_UNSTABLE_API=${{ matrix.unstable }}
cmake --build . --target install --config Release
- name: Install valgrind
Expand All @@ -63,22 +63,22 @@ jobs:
shell: bash
run: |
cd build
cmake .. -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DZENOHC_BUILD_WITH_SHARED_MEMORY=${{ matrix.shm }} -DZENOHC_BUILD_WITH_UNSTABLE_API=${{ matrix.unstable }}
cmake .. -DZENOHC_TREAT_WARNING_AS_ERROR=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DZENOHC_BUILD_WITH_SHARED_MEMORY=${{ matrix.shm }} -DZENOHC_BUILD_WITH_UNSTABLE_API=${{ matrix.unstable }}
cmake --build . --target tests --config Release
ctest -C Release --output-on-failure -E "(unit_z_api_alignment_test|build_z_build_static)"
- name: Build cmake tests with C++ compiler to make sure that C API is C++ compatible
shell: bash
run: |
cd build
cmake .. -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Debug -DZENOHC_BUILD_TESTS_WITH_CXX=TRUE -DZENOHC_BUILD_WITH_SHARED_MEMORY=${{ matrix.shm }} -DZENOHC_BUILD_WITH_UNSTABLE_API=${{ matrix.unstable }}
cmake .. -DZENOHC_TREAT_WARNING_AS_ERROR=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Debug -DZENOHC_BUILD_TESTS_WITH_CXX=TRUE -DZENOHC_BUILD_WITH_SHARED_MEMORY=${{ matrix.shm }} -DZENOHC_BUILD_WITH_UNSTABLE_API=${{ matrix.unstable }}
cmake --build . --target tests --config Debug
- name: Run cmake tests with zenoh-c as static library
shell: bash
run: |
cd build
cmake .. -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DZENOHC_BUILD_WITH_SHARED_MEMORY=${{ matrix.shm }} -DZENOHC_BUILD_WITH_UNSTABLE_API=${{ matrix.unstable }}
cmake .. -DZENOHC_TREAT_WARNING_AS_ERROR=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DZENOHC_BUILD_WITH_SHARED_MEMORY=${{ matrix.shm }} -DZENOHC_BUILD_WITH_UNSTABLE_API=${{ matrix.unstable }}
cmake --build . --target tests --config Release
ctest -C Release --output-on-failure -E "(unit_z_api_alignment_test|build_z_build_shared)"
Expand All @@ -92,15 +92,15 @@ jobs:
shell: bash
run: |
mkdir -p ../build_examples
cmake -S examples -B ../build_examples -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF
cmake -S examples -B ../build_examples -DZENOHC_TREAT_WARNING_AS_ERROR=ON -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF
cmake --build ../build_examples --config Debug
rm -rf ../build_examples
- name: Build examples with zenoh-c as installed package
shell: bash
run: |
mkdir -p build_examples && cd build_examples
cmake ../examples -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/local -DZENOHC_SOURCE=PACKAGE
cmake ../examples -DZENOHC_TREAT_WARNING_AS_ERROR=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/local -DZENOHC_SOURCE=PACKAGE
cmake --build . --config Release
cd .. && rm -rf build_examples
Expand Down
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ declare_cache_var(ZENOHC_CUSTOM_TARGET "" STRING "Rust target for cross compilat
declare_cache_var(ZENOHC_CARGO_CHANNEL "" STRING "Cargo channel parameter. Should be '+stable', '+nightly' or empty value")
declare_cache_var(ZENOHC_CARGO_FLAGS "" STRING "Additional cargo flags")
declare_cache_var(BUILD_SHARED_LIBS TRUE BOOL "Alias zenohc::lib target to zenohc::shared if TRUE, to zenohc::static if FALSE")
declare_cache_var(ZENOHC_TREAT_WARNING_AS_ERROR OFF BOOL "Whether to treat compilation warnings as errors")
set(CMAKE_COMPILE_WARNING_AS_ERROR ${ZENOHC_TREAT_WARNING_AS_ERROR})

#
# Setup project version
#
set(project_version "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
if(NOT DEFINED PROJECT_VERSION_TWEAK)
set(project_version "${project_version}")
Expand Down
2 changes: 1 addition & 1 deletion examples/z_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int main(int argc, char** argv) {
z_owned_closure_sample_t respond;
z_closure(&respond, callback, drop, (void*)(&pub));
z_owned_subscriber_t sub;
z_declare_subscriber(&sub, z_loan(session), z_loan(pong), z_move(respond), NULL);
z_declare_subscriber(z_loan(session), &sub, z_loan(pong), z_move(respond), NULL);
uint8_t* data = z_malloc(args.size);
for (int i = 0; i < args.size; i++) {
data[i] = i % 10;
Expand Down

0 comments on commit 43f93c9

Please sign in to comment.