From 115012a0b1d9617c07bae5c82a19125b3c692258 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Fri, 2 Apr 2021 17:35:13 +0200 Subject: build: create _objs target for each library Type: improvement Change-Id: I260580cf2d32ff949f44d80c764937ee6102486c Signed-off-by: Damjan Marion --- src/cmake/library.cmake | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/cmake/library.cmake b/src/cmake/library.cmake index fdd34691a12..37239f3d680 100644 --- a/src/cmake/library.cmake +++ b/src/cmake/library.cmake @@ -19,7 +19,13 @@ macro(add_vpp_library lib) ${ARGN} ) - add_library(${lib} SHARED ${ARG_SOURCES}) + set (lo ${lib}_objs) + add_library(${lo} OBJECT ${ARG_SOURCES}) + set_target_properties(${lo} PROPERTIES POSITION_INDEPENDENT_CODE ON) + + add_library(${lib} SHARED) + target_sources(${lib} PRIVATE $) + if(VPP_LIB_VERSION) set_target_properties(${lib} PROPERTIES SOVERSION ${VPP_LIB_VERSION}) endif() @@ -39,6 +45,7 @@ macro(add_vpp_library lib) ) if (ARG_LTO AND VPP_USE_LTO) + set_property(TARGET ${lo} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) set_property(TARGET ${lib} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) target_compile_options (${lib} PRIVATE "-ffunction-sections") target_compile_options (${lib} PRIVATE "-fdata-sections") @@ -66,11 +73,11 @@ macro(add_vpp_library lib) endif() if(NOT VPP_EXTERNAL_PROJECT) - add_dependencies(${lib} api_headers) + add_dependencies(${lo} api_headers) endif() if(ARG_DEPENDS) - add_dependencies(${lib} ${ARG_DEPENDS}) + add_dependencies(${lo} ${ARG_DEPENDS}) endif() # install headers -- cgit 1.2.3-korg