Skip to content

Commit 572a01f

Browse files
build(pico-sdk): 8 recipes pull midi2 via FetchContent
Drop the local midi2_cpp / midi2_c99 helper libraries that re-listed ${MIDI2_CPP_ROOT}/src/midi2.c as a source. Each Pico SDK recipe now declares the same FetchContent block (NOT TARGET midi2 -> v0.3.2 from GitHub by default; -DMIDI2_LOCAL_PATH overrides for offline builds) and links midi2::midi2 directly. Recipes touched: - rp2040-midi2 - waveshare-rp2040-midi2 - sparkfun-promicro-rp2350-midi2 - waveshare-rp2350-usb-a-midi2 - rp2040-promicro-ump-test-bench - adafruit-feather-rp2040-host-midi2 (keeps midi2_host.cpp local) - adafruit-feather-rp2040-bridge-midi2 (was midi2_c99-only) - waveshare-rp2350-usb-a-bridge-midi2 (was midi2_c99-only) The vendored src/midi2.{h,c} stays in the tree until the remaining build systems (TinyUSB native CMake, ESP-IDF, PlatformIO) follow.
1 parent 945f041 commit 572a01f

8 files changed

Lines changed: 150 additions & 16 deletions

File tree

examples/adafruit-feather-rp2040-bridge-midi2/CMakeLists.txt

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,23 @@ pico_sdk_init()
7171
# the single .c from the parent library tree to keep the binary lean.
7272
# ---------------------------------------------------------------------------
7373
set(MIDI2_CPP_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../..")
74-
add_library(midi2_c99 STATIC
75-
${MIDI2_CPP_ROOT}/src/midi2.c
76-
)
77-
target_include_directories(midi2_c99 PUBLIC ${MIDI2_CPP_ROOT}/src)
74+
75+
# midi2 C99 core, pulled externally so the recipe shares one source
76+
# of truth with the rest of the ecosystem. Override with
77+
# -DMIDI2_LOCAL_PATH=/path/to/midi2 for offline builds.
78+
include(FetchContent)
79+
if(NOT TARGET midi2)
80+
if(DEFINED MIDI2_LOCAL_PATH)
81+
FetchContent_Declare(midi2 SOURCE_DIR ${MIDI2_LOCAL_PATH})
82+
else()
83+
FetchContent_Declare(midi2
84+
GIT_REPOSITORY https://github.com/sauloverissimo/midi2.git
85+
GIT_TAG v0.3.2
86+
GIT_SHALLOW TRUE
87+
)
88+
endif()
89+
FetchContent_MakeAvailable(midi2)
90+
endif()
7891

7992
# ---------------------------------------------------------------------------
8093
# Showcase executable.
@@ -90,7 +103,7 @@ target_include_directories(adafruit-feather-rp2040-bridge-midi2-showcase PRIVATE
90103

91104
target_link_libraries(adafruit-feather-rp2040-bridge-midi2-showcase
92105
PRIVATE
93-
midi2_c99
106+
midi2::midi2
94107
pico_stdlib
95108
hardware_i2c # SSD1306 over I2C1
96109
tinyusb_device

examples/adafruit-feather-rp2040-host-midi2/CMakeLists.txt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,31 @@ pico_sdk_init()
7878
# copy needed.
7979
# ---------------------------------------------------------------------------
8080
set(MIDI2_CPP_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../..")
81+
82+
# midi2 C99 core, pulled externally so the recipe shares one source
83+
# of truth with the rest of the ecosystem. Override with
84+
# -DMIDI2_LOCAL_PATH=/path/to/midi2 for offline builds.
85+
include(FetchContent)
86+
if(NOT TARGET midi2)
87+
if(DEFINED MIDI2_LOCAL_PATH)
88+
FetchContent_Declare(midi2 SOURCE_DIR ${MIDI2_LOCAL_PATH})
89+
else()
90+
FetchContent_Declare(midi2
91+
GIT_REPOSITORY https://github.com/sauloverissimo/midi2.git
92+
GIT_TAG v0.3.2
93+
GIT_SHALLOW TRUE
94+
)
95+
endif()
96+
FetchContent_MakeAvailable(midi2)
97+
endif()
98+
8199
add_library(midi2_cpp STATIC
82-
${MIDI2_CPP_ROOT}/src/midi2.c
83100
${MIDI2_CPP_ROOT}/src/midi2_device.cpp
84101
${MIDI2_CPP_ROOT}/src/midi2_ci.cpp
85102
${MIDI2_CPP_ROOT}/src/midi2_host.cpp
86103
)
87104
target_include_directories(midi2_cpp PUBLIC ${MIDI2_CPP_ROOT}/src)
105+
target_link_libraries(midi2_cpp PUBLIC midi2::midi2)
88106

89107
# ---------------------------------------------------------------------------
90108
# Pico-PIO-USB sources compiled into our target. The library doesn't

examples/rp2040-midi2/CMakeLists.txt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,30 @@ pico_sdk_init()
5454
# root). No vendored copy needed.
5555
# ---------------------------------------------------------------------------
5656
set(MIDI2_CPP_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../..")
57+
58+
# midi2 C99 core, pulled externally so the recipe shares one source
59+
# of truth with the rest of the ecosystem. Override with
60+
# -DMIDI2_LOCAL_PATH=/path/to/midi2 for offline builds.
61+
include(FetchContent)
62+
if(NOT TARGET midi2)
63+
if(DEFINED MIDI2_LOCAL_PATH)
64+
FetchContent_Declare(midi2 SOURCE_DIR ${MIDI2_LOCAL_PATH})
65+
else()
66+
FetchContent_Declare(midi2
67+
GIT_REPOSITORY https://github.com/sauloverissimo/midi2.git
68+
GIT_TAG v0.3.2
69+
GIT_SHALLOW TRUE
70+
)
71+
endif()
72+
FetchContent_MakeAvailable(midi2)
73+
endif()
74+
5775
add_library(midi2_cpp STATIC
58-
${MIDI2_CPP_ROOT}/src/midi2.c
5976
${MIDI2_CPP_ROOT}/src/midi2_device.cpp
6077
${MIDI2_CPP_ROOT}/src/midi2_ci.cpp
6178
)
6279
target_include_directories(midi2_cpp PUBLIC ${MIDI2_CPP_ROOT}/src)
80+
target_link_libraries(midi2_cpp PUBLIC midi2::midi2)
6381

6482
# ---------------------------------------------------------------------------
6583
# rp2040-midi2 — board core (Pico SDK + TinyUSB glue + 5 hooks wired)

examples/rp2040-promicro-ump-test-bench/CMakeLists.txt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,30 @@ pico_sdk_init()
5858
# library root). No vendored copy needed.
5959
# ---------------------------------------------------------------------------
6060
set(MIDI2_CPP_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../..")
61+
62+
# midi2 C99 core, pulled externally so the recipe shares one source
63+
# of truth with the rest of the ecosystem. Override with
64+
# -DMIDI2_LOCAL_PATH=/path/to/midi2 for offline builds.
65+
include(FetchContent)
66+
if(NOT TARGET midi2)
67+
if(DEFINED MIDI2_LOCAL_PATH)
68+
FetchContent_Declare(midi2 SOURCE_DIR ${MIDI2_LOCAL_PATH})
69+
else()
70+
FetchContent_Declare(midi2
71+
GIT_REPOSITORY https://github.com/sauloverissimo/midi2.git
72+
GIT_TAG v0.3.2
73+
GIT_SHALLOW TRUE
74+
)
75+
endif()
76+
FetchContent_MakeAvailable(midi2)
77+
endif()
78+
6179
add_library(midi2_cpp STATIC
62-
${MIDI2_CPP_ROOT}/src/midi2.c
6380
${MIDI2_CPP_ROOT}/src/midi2_device.cpp
6481
${MIDI2_CPP_ROOT}/src/midi2_ci.cpp
6582
)
6683
target_include_directories(midi2_cpp PUBLIC ${MIDI2_CPP_ROOT}/src)
84+
target_link_libraries(midi2_cpp PUBLIC midi2::midi2)
6785

6886
# ---------------------------------------------------------------------------
6987
# rp2040-promicro-ump-test-bench, board core (Pico SDK + TinyUSB glue + 5 hooks

examples/sparkfun-promicro-rp2350-midi2/CMakeLists.txt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,30 @@ pico_sdk_init()
5050
# midi2_cpp, built from the parent library tree.
5151
# ---------------------------------------------------------------------------
5252
set(MIDI2_CPP_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../..")
53+
54+
# midi2 C99 core, pulled externally so the recipe shares one source
55+
# of truth with the rest of the ecosystem. Override with
56+
# -DMIDI2_LOCAL_PATH=/path/to/midi2 for offline builds.
57+
include(FetchContent)
58+
if(NOT TARGET midi2)
59+
if(DEFINED MIDI2_LOCAL_PATH)
60+
FetchContent_Declare(midi2 SOURCE_DIR ${MIDI2_LOCAL_PATH})
61+
else()
62+
FetchContent_Declare(midi2
63+
GIT_REPOSITORY https://github.com/sauloverissimo/midi2.git
64+
GIT_TAG v0.3.2
65+
GIT_SHALLOW TRUE
66+
)
67+
endif()
68+
FetchContent_MakeAvailable(midi2)
69+
endif()
70+
5371
add_library(midi2_cpp STATIC
54-
${MIDI2_CPP_ROOT}/src/midi2.c
5572
${MIDI2_CPP_ROOT}/src/midi2_device.cpp
5673
${MIDI2_CPP_ROOT}/src/midi2_ci.cpp
5774
)
5875
target_include_directories(midi2_cpp PUBLIC ${MIDI2_CPP_ROOT}/src)
76+
target_link_libraries(midi2_cpp PUBLIC midi2::midi2)
5977

6078
# ---------------------------------------------------------------------------
6179
# sparkfun-promicro-rp2350-midi2, board core (Pico SDK + TinyUSB glue +

examples/waveshare-rp2040-midi2/CMakeLists.txt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,30 @@ pico_sdk_init()
4848
# midi2_cpp, built from the parent library tree.
4949
# ---------------------------------------------------------------------------
5050
set(MIDI2_CPP_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../..")
51+
52+
# midi2 C99 core, pulled externally so the recipe shares one source
53+
# of truth with the rest of the ecosystem. Override with
54+
# -DMIDI2_LOCAL_PATH=/path/to/midi2 for offline builds.
55+
include(FetchContent)
56+
if(NOT TARGET midi2)
57+
if(DEFINED MIDI2_LOCAL_PATH)
58+
FetchContent_Declare(midi2 SOURCE_DIR ${MIDI2_LOCAL_PATH})
59+
else()
60+
FetchContent_Declare(midi2
61+
GIT_REPOSITORY https://github.com/sauloverissimo/midi2.git
62+
GIT_TAG v0.3.2
63+
GIT_SHALLOW TRUE
64+
)
65+
endif()
66+
FetchContent_MakeAvailable(midi2)
67+
endif()
68+
5169
add_library(midi2_cpp STATIC
52-
${MIDI2_CPP_ROOT}/src/midi2.c
5370
${MIDI2_CPP_ROOT}/src/midi2_device.cpp
5471
${MIDI2_CPP_ROOT}/src/midi2_ci.cpp
5572
)
5673
target_include_directories(midi2_cpp PUBLIC ${MIDI2_CPP_ROOT}/src)
74+
target_link_libraries(midi2_cpp PUBLIC midi2::midi2)
5775

5876
# ---------------------------------------------------------------------------
5977
# waveshare-rp2040-midi2, board core (Pico SDK + TinyUSB glue +

examples/waveshare-rp2350-usb-a-bridge-midi2/CMakeLists.txt

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,23 @@ pico_sdk_init()
6868
# midi2 (C99), only midi2_msg_word_count is used by the router.
6969
# ---------------------------------------------------------------------------
7070
set(MIDI2_CPP_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../..")
71-
add_library(midi2_c99 STATIC
72-
${MIDI2_CPP_ROOT}/src/midi2.c
73-
)
74-
target_include_directories(midi2_c99 PUBLIC ${MIDI2_CPP_ROOT}/src)
71+
72+
# midi2 C99 core, pulled externally so the recipe shares one source
73+
# of truth with the rest of the ecosystem. Override with
74+
# -DMIDI2_LOCAL_PATH=/path/to/midi2 for offline builds.
75+
include(FetchContent)
76+
if(NOT TARGET midi2)
77+
if(DEFINED MIDI2_LOCAL_PATH)
78+
FetchContent_Declare(midi2 SOURCE_DIR ${MIDI2_LOCAL_PATH})
79+
else()
80+
FetchContent_Declare(midi2
81+
GIT_REPOSITORY https://github.com/sauloverissimo/midi2.git
82+
GIT_TAG v0.3.2
83+
GIT_SHALLOW TRUE
84+
)
85+
endif()
86+
FetchContent_MakeAvailable(midi2)
87+
endif()
7588

7689
# ---------------------------------------------------------------------------
7790
# Showcase executable.
@@ -87,7 +100,7 @@ target_include_directories(waveshare-rp2350-usb-a-bridge-midi2-showcase PRIVATE
87100

88101
target_link_libraries(waveshare-rp2350-usb-a-bridge-midi2-showcase
89102
PRIVATE
90-
midi2_c99
103+
midi2::midi2
91104
pico_stdlib
92105
hardware_i2c # optional SSD1306 over I2C1
93106
tinyusb_device

examples/waveshare-rp2350-usb-a-midi2/CMakeLists.txt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,30 @@ pico_sdk_init()
5252
# midi2_cpp, built from the parent library tree.
5353
# ---------------------------------------------------------------------------
5454
set(MIDI2_CPP_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../..")
55+
56+
# midi2 C99 core, pulled externally so the recipe shares one source
57+
# of truth with the rest of the ecosystem. Override with
58+
# -DMIDI2_LOCAL_PATH=/path/to/midi2 for offline builds.
59+
include(FetchContent)
60+
if(NOT TARGET midi2)
61+
if(DEFINED MIDI2_LOCAL_PATH)
62+
FetchContent_Declare(midi2 SOURCE_DIR ${MIDI2_LOCAL_PATH})
63+
else()
64+
FetchContent_Declare(midi2
65+
GIT_REPOSITORY https://github.com/sauloverissimo/midi2.git
66+
GIT_TAG v0.3.2
67+
GIT_SHALLOW TRUE
68+
)
69+
endif()
70+
FetchContent_MakeAvailable(midi2)
71+
endif()
72+
5573
add_library(midi2_cpp STATIC
56-
${MIDI2_CPP_ROOT}/src/midi2.c
5774
${MIDI2_CPP_ROOT}/src/midi2_device.cpp
5875
${MIDI2_CPP_ROOT}/src/midi2_ci.cpp
5976
)
6077
target_include_directories(midi2_cpp PUBLIC ${MIDI2_CPP_ROOT}/src)
78+
target_link_libraries(midi2_cpp PUBLIC midi2::midi2)
6179

6280
# ---------------------------------------------------------------------------
6381
# waveshare-rp2350-usb-a-midi2, board core (Pico SDK + TinyUSB glue +

0 commit comments

Comments
 (0)