Detect undefined linked targets during CMake processing rather than linking
When building using UNIX/Make, if a library target is added to target_link_libraries
that does not exist in the project, it generates a linker error when running make. It would be helpful if undefined target references could be detected and reported during the CMake phase.
I realise this is a consequence of CMake processing undefined library targets as system libraries (i.e. -l<target>
), and thus a feature rather than a bug. Is there a practical way of keywording linked libraries to say "these links refer to targets in the project" and "these links are external and won't appear in the project" and thus allow CMake to fail early?
(Most common scenario is when there's a typo in the library name, and thus add_library
and target_link_libraries
don't match.)