December 30, 2023, 18:27
cmake cmake_minimum_required(VERSION 3.26) # Check if SDK exists, it not then fetch it from remote git set(PICO_SDK_FETCH_FROM_GIT ON) # Pull in Pico SDK include(pico_sdk_import.cmake) project(TestProject) # Initialise Pico SDK pico_sdk_init() # Main source files add_executable(TestProject src/main.c ) # Add pico_stdlib library which aggregates commonly used features target_link_libraries(TestProject pico_stdlib) # Create map/bin/hex/uf2 file in addition to ELF. pico_add_extra_outputs(TestProject)My CMakeLists reloads perfectly fine and the Pico SDK is fetched into the build cmake-build-pico build directory. I've used the blink example to test if this setup works:
c / Copyright (c) 2020 Raspberry Pi (Trading) Ltd. SPDX-License-Identifier: BSD-3-Clause / #include "pico/stdlib.h" int main() { #ifndef PICO_DEFAULT_LED_PIN #warning blink example requires a board with a regular LED #else const uint LED_PIN = PICO_DEFAULT_LED_PIN; gpio_init(LED_PIN); gpio_set_dir(LED_PIN, GPIO_OUT); while (true) { gpio_put(LED_PIN, 1); sleep_ms(250); gpio_put(LED_PIN, 0); sleep_ms(250); } #endif }When hovering over the import I get a syntax error "'pico/stdlib.h' file not found". When attempting to build I get the following:
====================[ Build | TestProject | Pico ]================================ C:\Users\Marcel\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\232.9921.42\bin\cmake\win\x64\bin\cmake.exe --build C:\Users\Marcel\CLionProjects\TestProject\cmake-build-pico --target TestProject -j 10 [1/51] Performing configure step for 'ELF2UF2Build' FAILED: elf2uf2/src/ELF2UF2Build-stamp/ELF2UF2Build-configure C:/Users/Marcel/CLionProjects/TestProject/cmake-build-pico/elf2uf2/src/ELF2UF2Build-stamp/ELF2UF2Build-configure cmd.exe /C "cd /D C:\Users\Marcel\CLionProjects\TestProject\cmake-build-pico\elf2uf2 && C:\Users\Marcel\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\232.9921.42\bin\cmake\win\x64\bin\cmake.exe -DCMAKE_MAKE_PROGRAM:FILEPATH=C:/Users/Marcel/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/ninja/win/x64/ninja.exe -GNinja -S C:/Users/Marcel/CLionProjects/TestProject/cmake-build-pico/_deps/pico_sdk-src/tools/elf2uf2 -B C:/Users/Marcel/CLionProjects/TestProject/cmake-build-pico/elf2uf2 && C:\Users\Marcel\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\232.9921.42\bin\cmake\win\x64\bin\cmake.exe -E touch C:/Users/Marcel/CLionProjects/TestProject/cmake-build-pico/elf2uf2/src/ELF2UF2Build-stamp/ELF2UF2Build-configure" -- The C compiler identification is unknown -- The CXX compiler identification is unknown CMake Error at CMakeLists.txt:2 (project): No CMAKE_C_COMPILER could be found. Tell CMake where to find the compiler by setting either the environment variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH. CMake Error at CMakeLists.txt:2 (project): No CMAKE_CXX_COMPILER could be found. Tell CMake where to find the compiler by setting either the environment variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH. -- Configuring incomplete, errors occurred! ninja: build stopped: subcommand failed.Tracing back to the files it seems to attempt to use, things like .../cmake-build-pico/elf2uf2/src/ELF2UF2Build-stamp/ELF2UF2Build-configure cmd.exe which aren't present as shown in the 2nd image. What am I doing wrong? Any resources I can use?