I am using CMake to build for embedded targets, and ran into something that was surprisingly challenging to do.
It is not uncommon to be given pre-compiled libraries as .a files, along with an interface in .h files.
The first results that turn up on google, I just could NOT get them to work.
For example, lets say if I have a “libvendor”, distributed as a libvendor_arm.a and vendor.h.
Like this, as it’s own CMakeLists.txt files in libs/libvendor/,
with add_subdirectory( libs/libvendor ) added to my base cmake script.
Using that, and linking vendor to my main exe target, include paths do not seem to get added, and builds fail with: cannot find -lvendor: No such file or directory
Have I … overlooked something? Is this idiomatically correct, such that I can then do: target_link_libraries( app.elf PUBLIC vendor ), and get the header interface AND linking to the .a ?
Oh. Ok. Would I use find_package even if it is something inside the repo, and not a package installed somewhere else in the system, or provided by the OS?
I am trying some versions of this, but just cannot get it to work …
This contains a typo. You’ve used a different target when you define the library (vendor) and when you set properties (cbt). Does your real project have that typo too?