mirror of
https://github.com/rockchip-linux/mpp.git
synced 2024-11-23 01:53:59 +08:00
fix[cmake]: fix static build
Signed-off-by: MarcA711 <40744649+MarcA711@users.noreply.github.com> Signed-off-by: Herman Chen <herman.chen@rock-chips.com> Change-Id: I4bd4a7543584685b20089d3953e700f5612523e7
This commit is contained in:
parent
efbf1ddafc
commit
9f9986752f
@ -294,8 +294,7 @@ endif(MSVC)
|
||||
# ----------------------------------------------------------------------------
|
||||
# Share library option
|
||||
# ----------------------------------------------------------------------------
|
||||
option(ENABLE_STATIC "Build shared library" ON)
|
||||
option(ENABLE_SHARED "Build shared library" OFF)
|
||||
option(BUILD_SHARED_LIBS "Build shared library" ON)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# scan all LOG_TAG for log information and generate module header file
|
||||
|
10
merge_static_lib.sh
Executable file
10
merge_static_lib.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd $1
|
||||
rm -rf mpp/lib'$2$'.a
|
||||
|
||||
SCRIPT=$'CREATE mpp/lib'$2$'.a\n'
|
||||
SCRIPT=$SCRIPT$(find . -name '*.a' -exec echo 'ADDLIB {}' \;)
|
||||
SCRIPT=$SCRIPT$'\nSAVE\nEND\n'
|
||||
|
||||
ar -M <<< $SCRIPT
|
@ -49,22 +49,6 @@ set (MPP_SRC
|
||||
set(MPP_VERSION "0")
|
||||
set(MPP_ABI_VERSION "1")
|
||||
|
||||
add_library(${MPP_STATIC} STATIC ${MPP_SRC})
|
||||
set_target_properties(${MPP_STATIC} PROPERTIES FOLDER "mpp" OUTPUT_NAME "${MPP_SHARED}")
|
||||
set_target_properties(${MPP_STATIC} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
|
||||
target_link_libraries(${MPP_STATIC} mpp_codec mpp_hal mpp_vproc
|
||||
${BEGIN_WHOLE_ARCHIVE} mpp_base ${END_WHOLE_ARCHIVE})
|
||||
|
||||
add_custom_command(TARGET ${MPP_STATIC} POST_BUILD
|
||||
COMMAND ${CMAKE_AR} x $<TARGET_FILE:${MPP_STATIC}>
|
||||
COMMAND ${CMAKE_AR} x $<TARGET_FILE:osal>
|
||||
COMMAND ${CMAKE_AR} x $<TARGET_FILE:mpp_base>
|
||||
COMMAND ${CMAKE_AR} rcs lib${MPP_SHARED}.a *.o
|
||||
COMMAND ${CMAKE_STRIP} --strip-debug lib${MPP_SHARED}.a
|
||||
COMMAND pwd
|
||||
COMMAND rm *.o
|
||||
)
|
||||
|
||||
add_library(${MPP_SHARED} SHARED ${MPP_SRC})
|
||||
set_target_properties(${MPP_SHARED} PROPERTIES FOLDER "mpp")
|
||||
set_target_properties(${MPP_SHARED} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
|
||||
@ -82,5 +66,22 @@ endif()
|
||||
|
||||
add_subdirectory(legacy)
|
||||
|
||||
install(TARGETS ${MPP_SHARED} LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||
install(TARGETS ${MPP_STATIC} ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||
if(BUILD_SHARED_LIBS)
|
||||
install(TARGETS ${MPP_SHARED} LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||
|
||||
else()
|
||||
add_library(${MPP_STATIC} STATIC ${MPP_SRC})
|
||||
set_target_properties(${MPP_STATIC} PROPERTIES FOLDER "mpp")
|
||||
set_target_properties(${MPP_STATIC} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
|
||||
target_link_libraries(${MPP_STATIC} mpp_codec mpp_hal mpp_vproc
|
||||
${BEGIN_WHOLE_ARCHIVE} mpp_base ${END_WHOLE_ARCHIVE})
|
||||
|
||||
add_custom_command(TARGET ${MPP_STATIC} POST_BUILD
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/merge_static_lib.sh ${CMAKE_BINARY_DIR} ${MPP_SHARED}
|
||||
COMMAND ${CMAKE_STRIP} --strip-debug ${CMAKE_BINARY_DIR}/mpp/lib${MPP_SHARED}.a
|
||||
COMMENT "Building a merged static lib."
|
||||
)
|
||||
|
||||
install(FILES ${CMAKE_BINARY_DIR}/mpp/lib${MPP_SHARED}.a TYPE LIB)
|
||||
|
||||
endif()
|
||||
|
Loading…
Reference in New Issue
Block a user