build: forward dependencies to arch-specific libs 37/29437/2
authorAloys Augustin <aloaugus@cisco.com>
Tue, 13 Oct 2020 13:43:00 +0000 (15:43 +0200)
committerDamjan Marion <dmarion@me.com>
Thu, 15 Oct 2020 19:41:45 +0000 (19:41 +0000)
Without this, if a multiarch source depends on a generated api header
for instance, the build would be racy between the api header generation
and the multiarch object compilation.

Type: improvement
Signed-off-by: Aloys Augustin <aloaugus@cisco.com>
Change-Id: I08fcd0e5a1c51398ac1a8f37cf6562064b400d4a

src/cmake/cpu.cmake
src/cmake/library.cmake
src/cmake/plugin.cmake

index c7ad1a4..37bc24c 100644 (file)
@@ -121,12 +121,15 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)")
   endif()
 endif()
 
-macro(vpp_library_set_multiarch_sources lib)
+macro(vpp_library_set_multiarch_sources lib deps)
   foreach(V ${MARCH_VARIANTS})
     list(GET V 0 VARIANT)
     list(GET V 1 VARIANT_FLAGS)
     set(l ${lib}_${VARIANT})
     add_library(${l} OBJECT ${ARGN})
+    if("${deps}")
+      add_dependencies(${l} ${deps})
+    endif()
     set_target_properties(${l} PROPERTIES POSITION_INDEPENDENT_CODE ON)
     target_compile_options(${l} PUBLIC "-DCLIB_MARCH_VARIANT=${VARIANT}")
     separate_arguments(VARIANT_FLAGS)
index d6a63d3..06248a5 100644 (file)
@@ -39,7 +39,7 @@ macro(add_vpp_library lib)
   )
 
   if(ARG_MULTIARCH_SOURCES)
-    vpp_library_set_multiarch_sources(${lib} ${ARG_MULTIARCH_SOURCES})
+    vpp_library_set_multiarch_sources(${lib} "${ARG_DEPENDS}" ${ARG_MULTIARCH_SOURCES})
   endif()
 
   if(ARG_API_FILES)
index c37e349..1bcff55 100644 (file)
@@ -45,17 +45,19 @@ macro(add_vpp_plugin name)
   endforeach()
   add_library(${plugin_name} SHARED ${PLUGIN_SOURCES} ${api_includes})
   set_target_properties(${plugin_name} PROPERTIES NO_SONAME 1)
+  set(deps "")
   if(PLUGIN_API_FILES)
-    add_dependencies(${plugin_name} ${plugin_name}_api_headers)
+    list(APPEND deps ${plugin_name}_api_headers)
   endif()
   if(NOT VPP_EXTERNAL_PROJECT)
-    add_dependencies(${plugin_name} vpp_version_h api_headers)
+    list(APPEND deps vpp_version_h api_headers)
   endif()
+  add_dependencies(${plugin_name} ${deps})
   set_target_properties(${plugin_name} PROPERTIES
     PREFIX ""
     LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/vpp_plugins)
   if(PLUGIN_MULTIARCH_SOURCES)
-    vpp_library_set_multiarch_sources(${plugin_name} ${PLUGIN_MULTIARCH_SOURCES})
+    vpp_library_set_multiarch_sources(${plugin_name} "${deps}" ${PLUGIN_MULTIARCH_SOURCES})
   endif()
   if(PLUGIN_LINK_LIBRARIES)
     target_link_libraries(${plugin_name} ${PLUGIN_LINK_LIBRARIES})