Why wouldn't pico_sdk_init.cmake first check if PICO_SDK_PATH Environment Variable is defined?
pico_sdk_import.cmake checks for an Environment VariableHere is a thread with more confusion.
Setting PICO_SDK_PATH in your CMakeLists.txt (hint: dont)
viewtopic.php?t=316408&start=50
Code:
if (NOT PICO_SDK_PATH) set(PICO_SDK_PATH ${CMAKE_CURRENT_LIST_DIR}) endif () get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}") set(PICO_SDK_PATH ${CMAKE_CURRENT_LIST_DIR} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE)
Code:
if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH)) set(PICO_SDK_PATH $ENV{PICO_SDK_PATH}) message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')")endif ()
Setting PICO_SDK_PATH in your CMakeLists.txt (hint: dont)
viewtopic.php?t=316408&start=50
pico_sdk_import.cmake is simply an inert piece of glue code that tries a few different ways to locate the pico-sdk and gives you sensible error messages if it can't. If we had somewhere else to put it other than in the SDK we'd have put it there as it isn't really part of the SDK.
The "init" script is in the SDK and is called pico_sdk_init.cmake (pico_sdk_import locates this file and includes it for you)
Yes you are entirely free to neither copy or use pico_sdk_import.cmake if you really want not to since it is in no way required by the SDK itself. Note that just doing and add_subdirectory with the pico-sdk works fine too, but you need to know where it is
Statistics: Posted by LemonPi — Thu Mar 07, 2024 6:02 pm