Adding target_include_directories or simply include_directories didn't seem to make a difference, but it made me realize that the problem may be with CLion itself.
To make sure that I have it configured properly, I changed add_library to add_executable and put everything from target_sources in it. Initially, the problem persisted, but after removing the pico_sdk_import.cmake include and pico_sdk_init, reloading CMake, adding them again and reloading, it was loading Pico SDK headers correctly. After changing add_executable to add_library again, the errors returned.
I noticed that the upper right corner, that usually shows the amounts of problems in a particular file, shows "OFF" when CMakeLists.txt has add_library instead of add_executable. The tooltip for that says "Analysis is not supported: Unable to find a project file to use".
Messing around with it for a bit, I noticed that if I remove the pico_sdk_import.cmake inlude and pico_sdk_init at the same time, it will analyze the files correctly if the library type is set to STATIC (and not find any Pico SDK header files, because I didn't include them, but at least it analyzes the file). If I add the include command back, optionally the pico_sdk_init command as well, it may keep working or stop working as a STATIC library. But if I change the type to INTERFACE, with or without the include, it will stop working. If the include is present, changing it back to STATIC will also not work.
Could this be a problem of CLion? In the project creation wizard there is not option to create an INTERFACE library, but that type is present in the autocomplete, along with STATIC and SHARED, so I wouldn't expect it to be unsupported.
To make sure that I have it configured properly, I changed add_library to add_executable and put everything from target_sources in it. Initially, the problem persisted, but after removing the pico_sdk_import.cmake include and pico_sdk_init, reloading CMake, adding them again and reloading, it was loading Pico SDK headers correctly. After changing add_executable to add_library again, the errors returned.
I noticed that the upper right corner, that usually shows the amounts of problems in a particular file, shows "OFF" when CMakeLists.txt has add_library instead of add_executable. The tooltip for that says "Analysis is not supported: Unable to find a project file to use".
Messing around with it for a bit, I noticed that if I remove the pico_sdk_import.cmake inlude and pico_sdk_init at the same time, it will analyze the files correctly if the library type is set to STATIC (and not find any Pico SDK header files, because I didn't include them, but at least it analyzes the file). If I add the include command back, optionally the pico_sdk_init command as well, it may keep working or stop working as a STATIC library. But if I change the type to INTERFACE, with or without the include, it will stop working. If the include is present, changing it back to STATIC will also not work.
Could this be a problem of CLion? In the project creation wizard there is not option to create an INTERFACE library, but that type is present in the autocomplete, along with STATIC and SHARED, so I wouldn't expect it to be unsupported.
Statistics: Posted by suprjd — Sat Jun 14, 2025 9:45 pm