Open Wirtos opened 3 years ago
Which part of your project was being built when you saw those errors? Note that building the toolchain also builds elf2uf2 (which converts the .elf
file that GCC generates into a .uf2
file for copying onto your Pico) which is a native (it runs on your computer rather than on your Pico) program written in C++.
Which part of your project was being built when you saw those errors? Note that building the toolchain also builds elf2uf2 (which converts the
.elf
file that GCC generates into a.uf2
file for copying onto your Pico) which is a native (it runs on your computer rather than on your Pico) program written in C++.
It breaks before the build process during generation as mentioned in the report. Does this regardlessly of me having add_extra_outputs. The toolchain config should be responsible for providing C++ compiler to build elf2uf2, not the project itself. But even considering that I'm not sure whether elf2uf2 is the root of the problem.
Yeah; fixing this is a bit nasty, because the SDK itself is a CXX project, and reports as such vi ENABLED_LANGUAGES property in cmake. Your project fails, because at the toplevel scope CXX is not a valid language. I had a little play and see that if the SDK doesn't include new_delete.cpp then you are fine, but as I say we can't simply check ENABLED_LANGUAGES as that does contain CXX at this point.
I don't feel strongly enough to expend much effort on it right now, so feel free to post a PR... I guess we could add a CMake build flag at least to say you want nothing to do with C++ assuming it is an actual requirement
See #339 for C99
I guess I'll try to toy with the toolchain later and maybe port tools like elf2uf2 to C then
elf2uf2 is not the problem; that is a separate build and works fine
So it's solely the toolchain that breaks because of undefined languages? It seems like it's quite trivial to use gcc-arm toolchain in place of CMAKE_TOOLCHAIN_FILE, but I'm not sure on how to link the libraries in this case. iirc vcpkg adds directories to CMAKE_FIND_ROOT_PATH in order to be able to use find_package or find_path. Can I do the same separately for pico toolchain and if yes, which dirs should I add?
I manage to solve this by using a variable PICO_SDK_PURE_C
to remove new_delete.cpp
from the source.
In src/rp2_common/pico_standard_link/CMakeLists.txt
replace
target_sources(pico_standard_link INTERFACE
${CMAKE_CURRENT_LIST_DIR}/crt0.S
${CMAKE_CURRENT_LIST_DIR}/new_delete.cpp
${CMAKE_CURRENT_LIST_DIR}/binary_info.c
)
by
set(pico_standard_link_SOURCES ${CMAKE_CURRENT_LIST_DIR}/crt0.S ${CMAKE_CURRENT_LIST_DIR}/binary_info.c)
if(NOT DEFINED PICO_SDK_PURE_C)
message("C++ enabled, add ${CMAKE_CURRENT_LIST_DIR}/new_delete.cpp")
set(pico_standard_link_SOURCES ${pico_standard_link_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/new_delete.cpp)
endif()
And then, in your CMakeList.txt
define add set(PICO_SDK_PURE_C 1)
before include(pico_sdk_import.cmake)
I manage to solve this by using a variable
PICO_SDK_PURE_C
to removenew_delete.cpp
from the source.In
src/rp2_common/pico_standard_link/CMakeLists.txt
replacetarget_sources(pico_standard_link INTERFACE ${CMAKE_CURRENT_LIST_DIR}/crt0.S ${CMAKE_CURRENT_LIST_DIR}/new_delete.cpp ${CMAKE_CURRENT_LIST_DIR}/binary_info.c )
by
set(pico_standard_link_SOURCES ${CMAKE_CURRENT_LIST_DIR}/crt0.S ${CMAKE_CURRENT_LIST_DIR}/binary_info.c) if(NOT DEFINED PICO_SDK_PURE_C) message("C++ enabled, add ${CMAKE_CURRENT_LIST_DIR}/new_delete.cpp") set(pico_standard_link_SOURCES ${pico_standard_link_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/new_delete.cpp) endif()
And then, in your
CMakeList.txt
define addset(PICO_SDK_PURE_C 1)
beforeinclude(pico_sdk_import.cmake)
Worked for me! Thank's a lot @Bolayniuss
In default examples
project
has no explicitly used languages, which impliesC
andCXX
LANGUAGES
, but if I set my project to be C only (which is correct), cmake fails to generate it. I think toolchain's internals should be separated from the project completely like VCPKG does.Error log:
CMakeLists.txt: