pico_sdk_init.cmake 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # Initialize the PICO SDK
  2. # This file must be included prior to the project() call
  3. if (_PICO_SDK_INIT)
  4. return()
  5. endif ()
  6. set(_PICO_SDK_INIT 1)
  7. function(pico_is_top_level_project VAR)
  8. string(TOLOWER ${CMAKE_CURRENT_LIST_DIR} __list_dir)
  9. string(TOLOWER ${CMAKE_SOURCE_DIR} __source_dir)
  10. if (__source_dir STREQUAL __list_dir)
  11. set(${VAR} 1 PARENT_SCOPE)
  12. else()
  13. set(${VAR} 0 PARENT_SCOPE)
  14. endif()
  15. endfunction()
  16. if (NOT PICO_SDK_PATH)
  17. set(PICO_SDK_PATH ${CMAKE_CURRENT_LIST_DIR})
  18. endif ()
  19. get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
  20. set(PICO_SDK_PATH ${CMAKE_CURRENT_LIST_DIR} CACHE PATH "Path to the Pico SDK" FORCE)
  21. list(APPEND CMAKE_MODULE_PATH ${PICO_SDK_PATH}/cmake)
  22. include(${CMAKE_CURRENT_LIST_DIR}/pico_sdk_version.cmake)
  23. include(pico_utils)
  24. message("Pico SDK is located at ${CMAKE_CURRENT_LIST_DIR}")
  25. include(pico_pre_load_platform)
  26. # todo perhaps this should be included by the platform instead?
  27. # We want to configure correct toolchain prior to project load
  28. include(pico_pre_load_toolchain)
  29. macro(pico_sdk_init)
  30. if (NOT CMAKE_PROJECT_NAME)
  31. message(WARNING "pico_sdk_init() should be called after the project is created (and languages added)")
  32. endif()
  33. add_subdirectory(${PICO_SDK_PATH} pico_sdk)
  34. endmacro()
  35. macro(add_sub_list_dirs var)
  36. foreach(LIST_DIR IN LISTS ${var})
  37. get_filename_component(SHORT_NAME "${LIST_DIR}" NAME)
  38. message("Including custom CMakeLists.txt ${SHORT_NAME}")
  39. add_subdirectory(${LIST_DIR} ${SHORT_NAME})
  40. endforeach()
  41. endmacro()