set(STATIC_LIBS lib1 lib2 lib3)
add_custom_target(merged_static_lib ALL DEPENDS ${STATIC_LIBS})
add_custom_command(TARGET merged_static_lib POST_BUILD
COMMAND echo "CREATE libfoo.a" > merge.mri
)
foreach(lib IN LISTS STATIC_LIBS)
add_custom_command(TARGET merged_static_lib POST_BUILD
COMMAND echo "ADDLIB $<TARGET_FILE:${lib}>" >> merge.mri
)
endforeach()
add_custom_command(TARGET merged_static_lib POST_BUILD
COMMAND echo "SAVE" >> merge.mri
COMMAND echo "END" >> merge.mri
COMMAND ar -M < merge.mri
COMMAND rm merge.mri
)