Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5114

SDK • Re: pico_sdk_import.cmake question

$
0
0
You can try it. Afterwards, run cmake in a command prompt from the same directory the *.cmake file resides. The cmake file should print a message if the `if` branch is taken.

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 ()
I found it doesn't, which lead to this question.
Works for me.

This is my 'CMakeLists.txt' file in full, basically your code with a 'project' item added to stop CMake complaints of it not being present, and an "[XYZZY]" added to the message to prove it is my message and not anything else CMake may produce -

Code:

project(test)if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH))    set(PICO_SDK_PATH $ENV{PICO_SDK_PATH})    message("[XYZZY] Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')")endif ()
It works on Raspberry Pi -

Code:

pi@Pi3B:/tmp $ cmake .[XYZZY} Using PICO_SDK_PATH from environment ('/home/pi/pico/pico-sdk')-- Configuring done-- Generating done-- Build files have been written to: /tmppi@Pi3B:/tmp $
And also on Windows 10 -

Code:

c:\Tmp>cmake .[XYZZY] Using PICO_SDK_PATH from environment ('C:\Program Files\Raspberry Pi\Pico SDK v1.5.1\pico-sdk')-- Configuring done-- Generating done-- Build files have been written to: C:/Tmpc:\Tmp>
And my environment variable setting -

Code:

c:\Tmp>echo %PICO_SDK_PATH%C:\Program Files\Raspberry Pi\Pico SDK v1.5.1\pico-sdk
So not so much "doesn't work" as why it's not working for you.

I would suggest adding these two lines to your CMake file and report what they show -

Code:

message("[1] >>>${PICO_SDK_PATH}<<<")message("[2] >>>$ENV{PICO_SDK_PATH}<<<")
For me, on Windows 10 -

Code:

[1] >>><<<[2] >>>C:\Program Files\Raspberry Pi\Pico SDK v1.5.1\pico-sdk<<<
That above testing was done using a top-level 'CMakeLists.txt' and you are talking about a '.cmake' file.

Perhaps the reason you don't see it working is that the '.cmake' file is never invoked ? If it isn't you won't ever see the message inside your 'if' test.

But my money would be on having a 'set(PICO_SDK_PATH ....)' somewhere in your 'CMakeLists.txt' or a '.cmake' you are using.

Or you are using VS Code and have configured 'PICO_SDK_PATH' in the 'CMake Tools' extension.

Or your VS Code isn't running with the same environment variable settings as when you are at the command line.

Or VS Code has got confused and isn't using those environment variables - I had that happen to me.

What actual problem did you encounter which set you off on your adventure ?

Statistics: Posted by hippy — Wed Mar 06, 2024 2:45 pm



Viewing all articles
Browse latest Browse all 5114

Trending Articles