0

While I am not new to programming or C++, I am totally new to CMake. My goal is to compile using VS Code a project that creates executables for the Pico (RP2040) and x86 executable of various unit tests to run on a Linux desktop.

I have created a project to use one of the Pico examples (which compiles and runs fine) and added a test folder that contains a single .cpp file for my unit test. I have no clue how to write a CMakeLists.txt file to compile the unit test into a desktop executable. Of course, in addition to creating the correct executable, the test file also needs to be able to include and link to the various pico code and libraries in order to test them.

So far, I know I need to include the test directory in the project's CMakeLists.txt file: add_subdirectory(test) but I am unsure where to place it. I also have this much for the test folder's CMakeLists.txt file:

add_executable(test_blink   unit_tests.cpp)

target_link_libraries(test_blink pico_stdlib)

This much does compile, but the executable is for the Pico, and I have not tried to include or link to any of the Pico libraries or my code for the Pico.

Any examples or someone who has added unit testing to a Pico project on VS Code would be very helpful.

Scott
  • 121
  • 4

0 Answers0