Skip to content

Commit 6442e74

Browse files
CMake: add build of examples
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
1 parent 1bbc17b commit 6442e74

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

.github/workflows/build.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
-DCMAKE_C_FLAGS="-Oz -g -Werror"
4949
- name: clang
5050
cmakeflags: >-
51+
-DBUILD_EXAMPLES=ON
5152
-DBUILD_SHARED_LIBS=ON
5253
-DCMAKE_BUILD_TYPE=Debug
5354
-DCMAKE_C_COMPILER=clang
@@ -56,6 +57,7 @@ jobs:
5657
-DCMAKE_CXX_FLAGS_DEBUG="-Werror"
5758
- name: linux-g++
5859
cmakeflags: >-
60+
-DBUILD_EXAMPLES=ON
5961
-DBUILD_SHARED_LIBS=ON
6062
-DCMAKE_BUILD_TYPE=Debug
6163
-DCMAKE_C_COMPILER=gcc
@@ -68,15 +70,16 @@ jobs:
6870
name: clang-small
6971
cmakeflags: >-
7072
-DBUILD_TESTING=OFF
73+
-DBUILD_TOOLS=OFF
7174
-DCMAKE_C_COMPILER=clang
7275
-DCMAKE_C_FLAGS="-Oz -g -Werror"
7376
-DCMAKE_CXX_COMPILER=clang++
7477
-DCMAKE_CXX_FLAGS="-O2 -g -Werror"
75-
-DWITH_TOOLS=OFF
7678
- os: macos-15-intel
7779
build_cfg:
7880
name: clang
7981
cmakeflags: >-
82+
-DBUILD_EXAMPLES=ON
8083
-DBUILD_SHARED_LIBS=ON
8184
-DCMAKE_BUILD_TYPE=Debug
8285
-DCMAKE_C_COMPILER=clang

CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ option(WITH_FLOATING_POINT "Use floating point code in TinyCBOR" ON)
3535
option(WITH_FREESTANDING "Compile TinyCBOR in C freestanding mode" OFF)
3636
if(WITH_FLOATING_POINT AND NOT WITH_FREESTANDING)
3737
option(WITH_CBOR2JSON "Compile code to convert from CBOR to JSON" ON)
38-
option(WITH_TOOLS "Compile the TinyCBOR tools" ON)
38+
option(BUILD_EXAMPLES "Compile the TinyCBOR examples" OFF)
39+
option(BUILD_TOOLS "Compile the TinyCBOR tools" ON)
3940
endif()
4041

4142
# Include additional modules that are used unconditionally
@@ -176,10 +177,13 @@ install(
176177
set(PROJECT_LIBRARIES TinyCBOR)
177178
include(PackageConfig)
178179

180+
if(BUILD_EXAMPLES)
181+
add_subdirectory(examples)
182+
endif()
179183
if(BUILD_TESTING)
180184
enable_testing()
181185
add_subdirectory(tests)
182186
endif()
183-
if(WITH_TOOLS)
187+
if(BUILD_TOOLS)
184188
add_subdirectory(tools)
185189
endif()

examples/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (C) 2025 Intel Corporation
2+
# SPDX-License-Identifier: MIT
3+
include(TinyCBORHelpers)
4+
5+
tinycbor_add_executable(simplereader simplereader.c)

0 commit comments

Comments
 (0)