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+ # Copyright 2020 (c) 2020 Raspberry Pi (Trading) Ltd.
7+ #
8+ # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
9+ # following conditions are met:
10+ #
11+ # 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
12+ # disclaimer.
13+ #
14+ # 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
15+ # disclaimer in the documentation and/or other materials provided with the distribution.
16+ #
17+ # 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
18+ # derived from this software without specific prior written permission.
19+ #
20+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
21+ # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26+ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
628if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH))
729 set (PICO_SDK_PATH $ENV{PICO_SDK_PATH} )
830 message ("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH} ')" )
@@ -18,9 +40,20 @@ if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_P
1840 message ("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH} ')" )
1941endif ()
2042
43+ if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_TAG} AND (NOT PICO_SDK_FETCH_FROM_GIT_TAG))
44+ set (PICO_SDK_FETCH_FROM_GIT_TAG $ENV{PICO_SDK_FETCH_FROM_GIT_TAG} )
45+ message ("Using PICO_SDK_FETCH_FROM_GIT_TAG from environment ('${PICO_SDK_FETCH_FROM_GIT_TAG} ')" )
46+ endif ()
47+
48+ if (PICO_SDK_FETCH_FROM_GIT AND NOT PICO_SDK_FETCH_FROM_GIT_TAG)
49+ set (PICO_SDK_FETCH_FROM_GIT_TAG "master" )
50+ message ("Using master as default value for PICO_SDK_FETCH_FROM_GIT_TAG" )
51+ endif ()
52+
2153set (PICO_SDK_PATH "${PICO_SDK_PATH} " CACHE PATH "Path to the Raspberry Pi Pico SDK" )
2254set (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" )
2355set (PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH} " CACHE FILEPATH "location to download SDK" )
56+ set (PICO_SDK_FETCH_FROM_GIT_TAG "${PICO_SDK_FETCH_FROM_GIT_TAG} " CACHE FILEPATH "release tag for SDK" )
2457
2558if (NOT PICO_SDK_PATH)
2659 if (PICO_SDK_FETCH_FROM_GIT)
@@ -29,25 +62,40 @@ if (NOT PICO_SDK_PATH)
2962 if (PICO_SDK_FETCH_FROM_GIT_PATH)
3063 get_filename_component (FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH} " REALPATH BASE_DIR "${CMAKE_SOURCE_DIR} " )
3164 endif ()
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 ()
65+ FetchContent_Declare (
66+ pico_sdk
67+ GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
68+ GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG}
69+ )
4770
4871 if (NOT pico_sdk)
4972 message ("Downloading Raspberry Pi Pico SDK" )
50- FetchContent_Populate (pico_sdk)
73+ # GIT_SUBMODULES_RECURSE was added in 3.17
74+ if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17.0" )
75+ FetchContent_Populate (
76+ pico_sdk
77+ QUIET
78+ GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
79+ GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG}
80+ GIT_SUBMODULES_RECURSE FALSE
81+
82+ SOURCE_DIR ${FETCHCONTENT_BASE_DIR} /pico_sdk-src
83+ BINARY_DIR ${FETCHCONTENT_BASE_DIR} /pico_sdk-build
84+ SUBBUILD_DIR ${FETCHCONTENT_BASE_DIR} /pico_sdk-subbuild
85+ )
86+ else ()
87+ FetchContent_Populate (
88+ pico_sdk
89+ QUIET
90+ GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
91+ GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG}
92+
93+ SOURCE_DIR ${FETCHCONTENT_BASE_DIR} /pico_sdk-src
94+ BINARY_DIR ${FETCHCONTENT_BASE_DIR} /pico_sdk-build
95+ SUBBUILD_DIR ${FETCHCONTENT_BASE_DIR} /pico_sdk-subbuild
96+ )
97+ endif ()
98+
5199 set (PICO_SDK_PATH ${pico_sdk_SOURCE_DIR} )
52100 endif ()
53101 set (FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE} )
0 commit comments