Issue
I am developing program for Raspberry Pi Pico. I am using Raspberry Pi Pico C/C++ SDK which uses cmake to build project.
I am developing the program on both Windows machine and on Raspberry Pi 4 (Linux).
In my CMakeLists.txt
I wish to programmatically switch the PICO_SDK_PATH
depending on type of machine I am using.
Windows Path
set(PICO_SDK_PATH "C:/Pico/pico-sdk")
Linux (Raspbian on raspberry Pi 4) Path
set(PICO_SDK_PATH "/home/xxx/Pico/pico-sdk")
I wish to do something like
#ifdef _Windows //depening on development machine
set(PICO_SDK_PATH "C:/Pico/pico-sdk")
#else
set(PICO_SDK_PATH "/home/xxx/Pico/pico-sdk")
How can I achieve the same.
Solution
On Windows, the WIN32
CMake variable is defined. You can use something like the following to set the variable:
if(WIN32)
set(PICO_SDK_PATH "C:/Pico/pico-sdk")
else()
set(PICO_SDK_PATH "/home/xxx/Pico/pico-sdk")
endif()
Answered By - Lindydancer Answer Checked By - Gilberto Lyons (WPSolving Admin)