Skip to content

Commit 4d01c0a

Browse files
build(tinyusb-cmake): xiao-samd21 and nrf52840 recipes pull midi2 via FetchContent
Mirror of the Pico SDK migration for the two TinyUSB native CMake recipes. Drop ${MIDI2_CPP_ROOT}/src/midi2.c from the local midi2_cpp helper library and link midi2::midi2 instead. The FetchContent block is identical so all CMake recipes share the same MIDI2_LOCAL_PATH override semantics.
1 parent 572a01f commit 4d01c0a

2 files changed

Lines changed: 38 additions & 2 deletions

File tree

examples/nrf52840-promicro-midi2/CMakeLists.txt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,30 @@ family_initialize_project(${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR})
7373
# midi2_cpp parent library (consumed via ../../src, not vendored)
7474
# ----------------------------------------------------------------------
7575
set(MIDI2_CPP_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../..")
76+
77+
# midi2 C99 core, pulled externally so the recipe shares one source
78+
# of truth with the rest of the ecosystem. Override with
79+
# -DMIDI2_LOCAL_PATH=/path/to/midi2 for offline builds.
80+
include(FetchContent)
81+
if(NOT TARGET midi2)
82+
if(DEFINED MIDI2_LOCAL_PATH)
83+
FetchContent_Declare(midi2 SOURCE_DIR ${MIDI2_LOCAL_PATH})
84+
else()
85+
FetchContent_Declare(midi2
86+
GIT_REPOSITORY https://github.com/sauloverissimo/midi2.git
87+
GIT_TAG v0.3.2
88+
GIT_SHALLOW TRUE
89+
)
90+
endif()
91+
FetchContent_MakeAvailable(midi2)
92+
endif()
93+
7694
add_library(midi2_cpp STATIC
77-
${MIDI2_CPP_ROOT}/src/midi2.c
7895
${MIDI2_CPP_ROOT}/src/midi2_device.cpp
7996
${MIDI2_CPP_ROOT}/src/midi2_ci.cpp
8097
)
8198
target_include_directories(midi2_cpp PUBLIC ${MIDI2_CPP_ROOT}/src)
99+
target_link_libraries(midi2_cpp PUBLIC midi2::midi2)
82100
target_compile_features(midi2_cpp PUBLIC cxx_std_17)
83101
target_compile_options(midi2_cpp PRIVATE -fno-rtti -fno-exceptions -fno-use-cxa-atexit)
84102

examples/xiao-samd21-midi2/CMakeLists.txt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,30 @@ family_initialize_project(${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR})
6363
# midi2_cpp parent library (consumed via ../../src, not vendored)
6464
# ----------------------------------------------------------------------
6565
set(MIDI2_CPP_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../..")
66+
67+
# midi2 C99 core, pulled externally so the recipe shares one source
68+
# of truth with the rest of the ecosystem. Override with
69+
# -DMIDI2_LOCAL_PATH=/path/to/midi2 for offline builds.
70+
include(FetchContent)
71+
if(NOT TARGET midi2)
72+
if(DEFINED MIDI2_LOCAL_PATH)
73+
FetchContent_Declare(midi2 SOURCE_DIR ${MIDI2_LOCAL_PATH})
74+
else()
75+
FetchContent_Declare(midi2
76+
GIT_REPOSITORY https://github.com/sauloverissimo/midi2.git
77+
GIT_TAG v0.3.2
78+
GIT_SHALLOW TRUE
79+
)
80+
endif()
81+
FetchContent_MakeAvailable(midi2)
82+
endif()
83+
6684
add_library(midi2_cpp STATIC
67-
${MIDI2_CPP_ROOT}/src/midi2.c
6885
${MIDI2_CPP_ROOT}/src/midi2_device.cpp
6986
${MIDI2_CPP_ROOT}/src/midi2_ci.cpp
7087
)
7188
target_include_directories(midi2_cpp PUBLIC ${MIDI2_CPP_ROOT}/src)
89+
target_link_libraries(midi2_cpp PUBLIC midi2::midi2)
7290
target_compile_features(midi2_cpp PUBLIC cxx_std_17)
7391
# midi2_cpp uses std::function / std::array; exceptions stay off (default
7492
# in arm-none-eabi-gcc with -fno-exceptions which TinyUSB build sets).

0 commit comments

Comments
 (0)