comparison pico_sdk_import.cmake @ 0:a55e39064a71

First commit of code that compiles. Does nothing like it should but has cmake goo to wrap dat files
author Daniel O'Connor <darius@dons.net.au>
date Mon, 29 Mar 2021 13:48:34 +1030
parents
children 2db42eaba3c8
comparison
equal deleted inserted replaced
-1:000000000000 0:a55e39064a71
1 # This is a copy of <PICO_SDK_PATH>/external/pico_sdk_import.cmake
2
3 # This can be dropped into an external project to help locate this SDK
4 # It should be include()ed prior to project()
5
6 if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH))
7 set(PICO_SDK_PATH $ENV{PICO_SDK_PATH})
8 message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')")
9 endif ()
10
11 if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT} AND (NOT PICO_SDK_FETCH_FROM_GIT))
12 set(PICO_SDK_FETCH_FROM_GIT $ENV{PICO_SDK_FETCH_FROM_GIT})
13 message("Using PICO_SDK_FETCH_FROM_GIT from environment ('${PICO_SDK_FETCH_FROM_GIT}')")
14 endif ()
15
16 if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_PATH))
17 set(PICO_SDK_FETCH_FROM_GIT_PATH $ENV{PICO_SDK_FETCH_FROM_GIT_PATH})
18 message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')")
19 endif ()
20
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")
23 set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK")
24
25 if (NOT PICO_SDK_PATH)
26 if (PICO_SDK_FETCH_FROM_GIT)
27 include(FetchContent)
28 set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR})
29 if (PICO_SDK_FETCH_FROM_GIT_PATH)
30 get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
31 endif ()
32 FetchContent_Declare(
33 pico_sdk
34 GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
35 GIT_TAG master
36 )
37 if (NOT pico_sdk)
38 message("Downloading Raspberry Pi Pico SDK")
39 FetchContent_Populate(pico_sdk)
40 set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR})
41 endif ()
42 set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})
43 else ()
44 message(FATAL_ERROR
45 "SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git."
46 )
47 endif ()
48 endif ()
49
50 get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
51 if (NOT EXISTS ${PICO_SDK_PATH})
52 message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' not found")
53 endif ()
54
55 set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake)
56 if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE})
57 message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the Raspberry Pi Pico SDK")
58 endif ()
59
60 set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE)
61
62 include(${PICO_SDK_INIT_CMAKE_FILE})