I'm trying to get a simple program that uses GPIO running on a Pico W. But I've run into a build issue. I'm 99% sure the problem is in my CMakeList.txt file. But it isn't apparent to me where I've made a mistake. I did try clearing my build directory and tried building again. This arrives at the same result. The error I get is as follows.
[ 96%] Built target squarewave_pio_squarewave_pio_h
[ 97%] Building CXX object CMakeFiles/squarewave_pio.dir/main.cpp.o
/home/j2inet/shares/projects/j2inet/irdetect/main.cpp:2:10: fatal error: pico/stdlib.h: No such file or directory
2 | #include "pico/stdlib.h"
| ^~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/squarewave_pio.dir/build.make:80: CMakeFiles/squarewave_pio.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1811: CMakeFiles/squarewave_pio.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
The source code for my project is on GitHub here in the addingGpio branch: https://github.com/j2inet/irdetect/tree/addingGpio
But I'll share what I think to be the most relevant part, which is my CMakeList.txt
cmake_minimum_required(VERSION 3.13)
include(pico_sdk_import.cmake)
project(test_project C CXX ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 23)
pico_sdk_init()
add_executable(irdetect
main.cpp
squarewave.pio
)
pico_enable_stdio_usb(irdetect 1)
pico_enable_stdio_uart(irdetect 1)
pico_add_extra_outputs(irdetect)
add_library(squarewave_pio squarewave.pio)
pico_generate_pio_header(squarewave_pio ${CMAKE_CURRENT_LIST_DIR}/pio/squarewave.pio)
target_sources(squarewave_pio PRIVATE main.cpp)
target_link_libraries(irdetect pico_stdlib pico_cyw43_arch_none hardware_pio)
pico_add_extra_outputs(squarewave_pio)
I build with the command cmake .. -DPICO_BOARD=pico_w && make from my ./build subfolder.
The include section of the source code doesn't contain anything that stands out as unusual to me.
#include <stdio.h>
#include "pico/stdlib.h"
#include "hardware/gpio.h"
#include "pico/binary_info.h"
#include "pico/cyw43_arch.h"
#include "build/squarewave.pio.h"