Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

pico_sdk_import.cmake 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # This is a copy of <PICO_SDK_PATH>/external/pico_sdk_import.cmake
  2. # This can be dropped into an external project to help locate this SDK
  3. # It should be include()ed prior to project()
  4. if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH))
  5. set(PICO_SDK_PATH $ENV{PICO_SDK_PATH})
  6. message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')")
  7. endif ()
  8. if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT} AND (NOT PICO_SDK_FETCH_FROM_GIT))
  9. set(PICO_SDK_FETCH_FROM_GIT $ENV{PICO_SDK_FETCH_FROM_GIT})
  10. message("Using PICO_SDK_FETCH_FROM_GIT from environment ('${PICO_SDK_FETCH_FROM_GIT}')")
  11. endif ()
  12. if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_PATH))
  13. set(PICO_SDK_FETCH_FROM_GIT_PATH $ENV{PICO_SDK_FETCH_FROM_GIT_PATH})
  14. message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')")
  15. endif ()
  16. set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK")
  17. 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")
  18. set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK")
  19. if (NOT PICO_SDK_PATH)
  20. if (PICO_SDK_FETCH_FROM_GIT)
  21. include(FetchContent)
  22. set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR})
  23. if (PICO_SDK_FETCH_FROM_GIT_PATH)
  24. get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
  25. endif ()
  26. # GIT_SUBMODULES_RECURSE was added in 3.17
  27. if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17.0")
  28. FetchContent_Declare(
  29. pico_sdk
  30. GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
  31. GIT_TAG master
  32. GIT_SUBMODULES_RECURSE FALSE
  33. )
  34. else ()
  35. FetchContent_Declare(
  36. pico_sdk
  37. GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
  38. GIT_TAG master
  39. )
  40. endif ()
  41. if (NOT pico_sdk)
  42. message("Downloading Raspberry Pi Pico SDK")
  43. FetchContent_Populate(pico_sdk)
  44. set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR})
  45. endif ()
  46. set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})
  47. else ()
  48. message(FATAL_ERROR
  49. "SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git."
  50. )
  51. endif ()
  52. endif ()
  53. get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
  54. if (NOT EXISTS ${PICO_SDK_PATH})
  55. message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' not found")
  56. endif ()
  57. set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake)
  58. if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE})
  59. message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the Raspberry Pi Pico SDK")
  60. endif ()
  61. set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE)
  62. include(${PICO_SDK_INIT_CMAKE_FILE})