Skip to content
Merged
Show file tree
Hide file tree
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
58 changes: 58 additions & 0 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Examples
permissions: read-all

on:
workflow_dispatch:
merge_group:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
DEBIAN_FRONTEND: noninteractive
CMAKE_GENERATOR: Ninja
DEFAULT_CXX_STANDARD: 20
DEFAULT_LLVM_VERSION: 21

jobs:
examples:
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-24.04
steps:
- name: Checkout PR branch
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: Install build tools
run: |
wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh ${{env.DEFAULT_LLVM_VERSION}}
sudo apt install -y ninja-build

- name: Restore CPM cache
env:
cache-name: cpm-cache-0
id: cpm-cache-restore
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: ~/cpm-cache
key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
restore-keys: |
${{runner.os}}-${{env.cache-name}}-

- name: Configure CMake
env:
CC: "/usr/lib/llvm-${{env.DEFAULT_LLVM_VERSION}}/bin/clang"
CXX: "/usr/lib/llvm-${{env.DEFAULT_LLVM_VERSION}}/bin/clang++"
PR_TARGET_BRANCH: ${{ steps.target_branch.outputs.branch }}
run: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_STANDARD=${{env.DEFAULT_CXX_STANDARD}} -DCPM_SOURCE_CACHE=~/cpm-cache

- name: Save CPM cache
env:
cache-name: cpm-cache-0
if: steps.cpm-cache-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: ~/cpm-cache
key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}

- name: Build examples
run: cmake --build ${{github.workspace}}/build -t examples
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/build
build/
/cmake-build-*
/venv
/.vscode
Expand Down
20 changes: 17 additions & 3 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
add_subdirectory(hello_world)
add_subdirectory(cib_serial_port)
add_subdirectory(flow_daily_routine)
add_custom_target(examples)

function(add_example)
set(singleValueArgs NAME)
set(multiValueArgs FILES)
cmake_parse_arguments(EX "" "${singleValueArgs}" "${multiValueArgs}"
${ARGN})
string(PREPEND EX_NAME "EXAMPLE.")

add_executable(${EX_NAME} ${EX_FILES})
target_link_libraries(${EX_NAME} cib)
add_dependencies(examples ${EX_NAME})
endfunction()

add_subdirectory(flow)
add_subdirectory(log)
add_subdirectory(nexus)
26 changes: 0 additions & 26 deletions examples/cib_serial_port/CMakeLists.txt

This file was deleted.

1 change: 1 addition & 0 deletions examples/flow/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(daily_routine)
39 changes: 39 additions & 0 deletions examples/flow/daily_routine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
cmake_minimum_required(VERSION 3.25)

project(daily_routine LANGUAGES CXX)

if(NOT TARGET cib)
# to fetch cib, either use CPM (https://github.com/cpm-cmake/CPM.cmake) or
# use plain old CMake functionality
set(USE_CPM 1)

set(CIB_VERSION "c388a4d") # update this to a more recent commit ID (or tag)
# for your project

if(USE_CPM)
file(
DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.42.0/CPM.cmake
${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake
EXPECTED_HASH
SHA256=2020b4fc42dba44817983e06342e682ecfc3d2f484a581f11cc5731fbe4dce8a
)
include(${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake)

cpmaddpackage("gh:intel/compile-time-init-build#${CIB_VERSION}")
else()
include(FetchContent)
FetchContent_Declare(
cib
GIT_REPOSITORY https://github.com/intel/compile-time-init-build.git
GIT_TAG ${CIB_VERSION})
FetchContent_MakeAvailable(cib)
endif()
endif()

if(COMMAND add_example)
add_example(NAME daily_routine FILES main.cpp)
else()
add_executable(daily_routine main.cpp)
target_link_libraries(daily_routine cib)
endif()
26 changes: 0 additions & 26 deletions examples/flow_daily_routine/CMakeLists.txt

This file was deleted.

26 changes: 0 additions & 26 deletions examples/hello_world/CMakeLists.txt

This file was deleted.

1 change: 1 addition & 0 deletions examples/log/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 2 additions & 0 deletions examples/nexus/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_subdirectory(hello_world)
add_subdirectory(serial_port)
39 changes: 39 additions & 0 deletions examples/nexus/hello_world/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
cmake_minimum_required(VERSION 3.25)

project(hello_world LANGUAGES CXX)

if(NOT TARGET cib)
# to fetch cib, either use CPM (https://github.com/cpm-cmake/CPM.cmake) or
# use plain old CMake functionality
set(USE_CPM 1)

set(CIB_VERSION "c388a4d") # update this to a more recent commit ID (or tag)
# for your project

if(USE_CPM)
file(
DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.42.0/CPM.cmake
${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake
EXPECTED_HASH
SHA256=2020b4fc42dba44817983e06342e682ecfc3d2f484a581f11cc5731fbe4dce8a
)
include(${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake)

cpmaddpackage("gh:intel/compile-time-init-build#${CIB_VERSION}")
else()
include(FetchContent)
FetchContent_Declare(
cib
GIT_REPOSITORY https://github.com/intel/compile-time-init-build.git
GIT_TAG ${CIB_VERSION})
FetchContent_MakeAvailable(cib)
endif()
endif()

if(COMMAND add_example)
add_example(NAME hello_world FILES main.cpp dont_panic.cpp)
else()
add_executable(hello_world main.cpp dont_panic.cpp)
target_link_libraries(hello_world cib)
endif()
File renamed without changes.
File renamed without changes.
File renamed without changes.
39 changes: 39 additions & 0 deletions examples/nexus/serial_port/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
cmake_minimum_required(VERSION 3.25)

project(serial_port LANGUAGES CXX)

if(NOT TARGET cib)
# to fetch cib, either use CPM (https://github.com/cpm-cmake/CPM.cmake) or
# use plain old CMake functionality
set(USE_CPM 1)

set(CIB_VERSION "c388a4d") # update this to a more recent commit ID (or tag)
# for your project

if(USE_CPM)
file(
DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.42.0/CPM.cmake
${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake
EXPECTED_HASH
SHA256=2020b4fc42dba44817983e06342e682ecfc3d2f484a581f11cc5731fbe4dce8a
)
include(${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake)

cpmaddpackage("gh:intel/compile-time-init-build#${CIB_VERSION}")
else()
include(FetchContent)
FetchContent_Declare(
cib
GIT_REPOSITORY https://github.com/intel/compile-time-init-build.git
GIT_TAG ${CIB_VERSION})
FetchContent_MakeAvailable(cib)
endif()
endif()

if(COMMAND add_example)
add_example(NAME serial_port FILES main.cpp)
else()
add_executable(serial_port main.cpp)
target_link_libraries(serial_port cib)
endif()
File renamed without changes.
Loading