1
+ #[[
2
+ Copyright 2020 (c) 2020 Raspberry Pi (Trading) Ltd.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
5
+ following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
8
+ disclaimer.
9
+
10
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
11
+ disclaimer in the documentation and/or other materials provided with the distribution.
12
+
13
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
14
+ derived from this software without specific prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
17
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ ]]
24
+
25
+
26
+ # Newest version of this file can be found at :
27
+ # https://github.com/raspberrypi/pico-sdk/blob/master/external/pico_sdk_import.cmake
28
+
29
+ # This is a copy of https://github.com/raspberrypi/pico-sdk/blob/1.5.1/external/pico_sdk_import.cmake
30
+
31
+ # This can be dropped into an external project to help locate this SDK
32
+ # It should be include()ed prior to project()
33
+
34
+ if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH))
35
+ set (PICO_SDK_PATH $ENV{PICO_SDK_PATH} )
36
+ message ("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH} ')" )
37
+ endif ()
38
+
39
+ if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT} AND (NOT PICO_SDK_FETCH_FROM_GIT))
40
+ set (PICO_SDK_FETCH_FROM_GIT $ENV{PICO_SDK_FETCH_FROM_GIT} )
41
+ message ("Using PICO_SDK_FETCH_FROM_GIT from environment ('${PICO_SDK_FETCH_FROM_GIT} ')" )
42
+ endif ()
43
+
44
+ if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_PATH))
45
+ set (PICO_SDK_FETCH_FROM_GIT_PATH $ENV{PICO_SDK_FETCH_FROM_GIT_PATH} )
46
+ message ("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH} ')" )
47
+ endif ()
48
+
49
+ set (PICO_SDK_PATH "${PICO_SDK_PATH} " CACHE PATH "Path to the Raspberry Pi Pico SDK" )
50
+ 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" )
51
+ set (PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH} " CACHE FILEPATH "location to download SDK" )
52
+
53
+ if (NOT PICO_SDK_PATH)
54
+ if (PICO_SDK_FETCH_FROM_GIT)
55
+ include (FetchContent)
56
+ set (FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR} )
57
+ if (PICO_SDK_FETCH_FROM_GIT_PATH)
58
+ get_filename_component (FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH} " REALPATH BASE_DIR "${CMAKE_SOURCE_DIR} " )
59
+ endif ()
60
+ # GIT_SUBMODULES_RECURSE was added in 3.17
61
+ if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17.0" )
62
+ FetchContent_Declare(
63
+ pico_sdk
64
+ GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
65
+ GIT_TAG master
66
+ GIT_SUBMODULES_RECURSE FALSE
67
+ )
68
+ else ()
69
+ FetchContent_Declare(
70
+ pico_sdk
71
+ GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
72
+ GIT_TAG master
73
+ )
74
+ endif ()
75
+
76
+ if (NOT pico_sdk)
77
+ message ("Downloading Raspberry Pi Pico SDK" )
78
+ FetchContent_Populate(pico_sdk)
79
+ set (PICO_SDK_PATH ${pico_sdk_SOURCE_DIR} )
80
+ endif ()
81
+ set (FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE} )
82
+ else ()
83
+ message (FATAL_ERROR
84
+ "SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git."
85
+ )
86
+ endif ()
87
+ endif ()
88
+
89
+ get_filename_component (PICO_SDK_PATH "${PICO_SDK_PATH} " REALPATH BASE_DIR "${CMAKE_BINARY_DIR} " )
90
+ if (NOT EXISTS ${PICO_SDK_PATH} )
91
+ message (FATAL_ERROR "Directory '${PICO_SDK_PATH} ' not found" )
92
+ endif ()
93
+
94
+ set (PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH} /pico_sdk_init.cmake)
95
+ if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE} )
96
+ message (FATAL_ERROR "Directory '${PICO_SDK_PATH} ' does not appear to contain the Raspberry Pi Pico SDK" )
97
+ endif ()
98
+
99
+ set (PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE)
100
+
101
+ include (${PICO_SDK_INIT_CMAKE_FILE} )
0 commit comments