33# This can be dropped into an external project to help locate this SDK
44# It should be include()ed prior to project()
55
6- # todo document
7-
86if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH))
97 set (PICO_SDK_PATH $ENV{PICO_SDK_PATH} )
108 message ("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH} ')" )
@@ -20,8 +18,8 @@ if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_P
2018 message ("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH} ')" )
2119endif ()
2220
23- set (PICO_SDK_PATH "${PICO_SDK_PATH} " CACHE PATH "Path to the PICO SDK" )
24- set (PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT} " CACHE BOOL "Set to ON to fetch copy of PICO SDK from git if not otherwise locatable" )
21+ set (PICO_SDK_PATH "${PICO_SDK_PATH} " CACHE PATH "Path to the Raspberry Pi Pico SDK" )
22+ set (PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT} " CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable" )
2523set (PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH} " CACHE FILEPATH "location to download SDK" )
2624
2725if (NOT PICO_SDK_PATH)
@@ -31,20 +29,31 @@ if (NOT PICO_SDK_PATH)
3129 if (PICO_SDK_FETCH_FROM_GIT_PATH)
3230 get_filename_component (FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH} " REALPATH BASE_DIR "${CMAKE_SOURCE_DIR} " )
3331 endif ()
34- FetchContent_Declare (
35- pico_sdk
36- GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
37- GIT_TAG master
38- )
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+
3948 if (NOT pico_sdk)
40- message ("Downloading PICO SDK" )
49+ message ("Downloading Raspberry Pi Pico SDK" )
4150 FetchContent_Populate (pico_sdk)
4251 set (PICO_SDK_PATH ${pico_sdk_SOURCE_DIR} )
4352 endif ()
4453 set (FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE} )
4554 else ()
4655 message (FATAL_ERROR
47- "PICO SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git."
56+ "SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git."
4857 )
4958 endif ()
5059endif ()
@@ -56,9 +65,9 @@ endif ()
5665
5766set (PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH} /pico_sdk_init.cmake)
5867if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE} )
59- message (FATAL_ERROR "Directory '${PICO_SDK_PATH} ' does not appear to contain the PICO SDK" )
68+ message (FATAL_ERROR "Directory '${PICO_SDK_PATH} ' does not appear to contain the Raspberry Pi Pico SDK" )
6069endif ()
6170
62- set (PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the PICO SDK" FORCE )
71+ set (PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE )
6372
6473include (${PICO_SDK_INIT_CMAKE_FILE} )
0 commit comments