build: fix missing dependency for library

When building a VPP library out of tree using add_vpp_library, the build
sometimes fails because the library API files are not necessarily
generated before compiling this library.

This is fixed by adding the lib API files as dependencies of the
lib compilation.

Type: fix
Signed-off-by: Guillaume Solignac <gsoligna@cisco.com>
Change-Id: I69dffaecbfd547f10115504494a47358c4624258
diff --git a/src/cmake/library.cmake b/src/cmake/library.cmake
index fbb2c68..ad4adfc 100644
--- a/src/cmake/library.cmake
+++ b/src/cmake/library.cmake
@@ -80,6 +80,10 @@
     add_dependencies(${lo} api_headers)
   endif()
 
+  if(VPP_EXTERNAL_PROJECT AND ARG_API_FILES)
+    add_dependencies(${lo} ${lib}_api_headers)
+  endif()
+
   if(ARG_DEPENDS)
     add_dependencies(${lo} ${ARG_DEPENDS})
   endif()