Skip to content

Commit 38b26b5

Browse files
authored
pico_sdk_import: don't recurse git submodules (earlephilhower#772)
When cloning the pico-sdk repo manually, one normally would do `git submodule update --init`, which is non-recursive. However, when cloning automatically, CMake will recursively update submodules by default. Updating all of tiny-usb's submodules takes an extremely long time. Luckily, CMake 3.17 added an option we can specify for FetchContent to tell it not to recursively update submodules. On older CMake versions, the flag is not used. For those with a new enough version of CMake, this will significantly speed up SDK cloning. Fixes earlephilhower#771.
1 parent d54104a commit 38b26b5

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

external/pico_sdk_import.cmake

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,22 @@ if (NOT PICO_SDK_PATH)
2929
if (PICO_SDK_FETCH_FROM_GIT_PATH)
3030
get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
3131
endif ()
32-
FetchContent_Declare(
33-
pico_sdk
34-
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
35-
GIT_TAG master
36-
)
32+
# GIT_SUBMODULES_RECURSE was added in 3.17
33+
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17.0")
34+
FetchContent_Declare(
35+
pico_sdk
36+
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
37+
GIT_TAG master
38+
GIT_SUBMODULES_RECURSE FALSE
39+
)
40+
else ()
41+
FetchContent_Declare(
42+
pico_sdk
43+
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
44+
GIT_TAG master
45+
)
46+
endif ()
47+
3748
if (NOT pico_sdk)
3849
message("Downloading Raspberry Pi Pico SDK")
3950
FetchContent_Populate(pico_sdk)

0 commit comments

Comments
 (0)