Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong value for PICO_SDK_PATH after automatic download from git #1639

Open
stefanschober opened this issue Feb 19, 2024 · 2 comments
Open

Wrong value for PICO_SDK_PATH after automatic download from git #1639

stefanschober opened this issue Feb 19, 2024 · 2 comments
Assignees
Labels
Milestone

Comments

@stefanschober
Copy link

I'm configuring pico_sdk from my project with the following settings:

  • PICO_SDK_FETCH_FROM_GIT set to TRUE
  • PICO_SDK_FETCH_FROM_GIT_PATH set to the absolute target path for the pico_sdk

When configuring the project, pico_sdk is downloaded into ${PICO_SDK_FETCH_FROM_GIT_PATH}/pico_sdk-src. The value of PICO_SDK_PATH is however set to ${PICO_SDK_FETCH_FROM_GIT_PATH}.

I fixed this like so:

--- ../pico-sdk/pico_sdk-src/external/pico_sdk_import.cmake     2024-02-19 10:23:26.764972800 +0100
+++ cmake/pico_sdk_import.cmake 2024-02-19 11:47:44.588034900 +0100
@@ -58,14 +59,20 @@
     endif ()
 endif ()

-get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
+file(REAL_PATH "${PICO_SDK_PATH}" PICO_SDK_PATH BASE_DIRECTORY "${CMAKE_BINARY_DIR}")
 if (NOT EXISTS ${PICO_SDK_PATH})
     message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' not found")
 endif ()

-set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake)
+find_file(PICO_SDK_INIT_CMAKE_FILE pico_sdk_init.cmake
+    HINTS ${PICO_SDK_PATH}
+    PATH_SUFFIXES pico_sdk-src
+)
+# set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake)
 if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE})
     message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the Raspberry Pi Pico SDK")
+else()
+    cmake_path(GET PICO_SDK_INIT_CMAKE_FILE PARENT_PATH PICO_SDK_PATH)
 endif ()

 set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE)
@stefanschober stefanschober changed the title Wrong value for PICO_SDK_PATH after automatic downloadi from git Wrong value for PICO_SDK_PATH after automatic download from git Feb 19, 2024
@stefanschober
Copy link
Author

happens when re-configuring the project using cmake ... --fresh

@kilograham kilograham added this to the 1.6.1 milestone May 20, 2024
@will-v-pi will-v-pi modified the milestones: 1.6.1, 1.6.0 Jul 23, 2024
@will-v-pi
Copy link

@stefanschober I can't reproduce this, but it could be a cmake caching issue. Does replacing set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR}) with set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE) (line 51 of that file) fix the issue for you?

The pico_sdk_SOURCE_DIR variable is set correctly to ${PICO_SDK_FETCH_FROM_GIT_PATH}/pico_sdk-src by FetchContent, so it should set the PICO_SDK_PATH to the correct value

@kilograham kilograham modified the milestones: 1.6.0, 1.7.0 Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants