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

SDK • Re: pico_sdk_import.cmake question

$
0
0
This line checks if the environment variable PICO_SDK_PATH is defined and evaluates to true, and if the value of PICO_SDK_PATH is not empty.

The DEFINED keyword checks if the variable is defined in the environment.
The ENV{PICO_SDK_PATH} part accesses the environment variable PICO_SDK_PATH.
The AND keyword is a logical operator that combines conditions, requiring both conditions to be true for the whole expression to be true.
The (NOT PICO_SDK_PATH) part negates the value of PICO_SDK_PATH, ensuring it's not empty.

Regarding your question about whether it will ever be true, it depends on how the environment is set up. If PICO_SDK_PATH is defined and has a non-empty value, then this condition will be true. If PICO_SDK_PATH is not defined or is defined but empty, the condition will evaluate to false.

As for your suggestion:

Code:

if (DEFINED ENV{PICO_SDK_PATH})
This would check only if the environment variable is defined, regardless of its value. If you don't need to ensure that the variable has a non-empty value, this would be sufficient and perhaps cleaner.

Statistics: Posted by embeddedbarsha — Tue Mar 05, 2024 8:55 am



Viewing all articles
Browse latest Browse all 5065

Trending Articles