Hello,
I am working on a project for an embedded MCU (STM32). And I am trying to set up unit testing with googletest which builds and runs natively.
- How can I build these two with one single
cmake --build
command?
I was thinking of using ExternalProject_Add()
in the top-level CMakeLists.txt to add the lib
folder and re-configure with the native compiler at the build time.
./project
./src
main.cpp
CMakeLists.txt
./lib
lib_a.cpp
lib_a.hpp
lib_test.cpp
CMakeLists.txt
CMakeLists.txt
lib_test.cpp
: Should build natively using GCC and run on the host.
main.cpp
: Should build using Arm toolchain.
- What would be the best directory structure for this project?
Do you think lib_test.cpp
would be better in a separate folder (i.e. tests
)? and why?