cpp-main/cpp-tbox

希望增加.cmake文件,方便使用CMakelist编译时引用

pd-unprofessional opened this issue · 1 comments

在编译生成静态库之后,使用CMakelist链接静态库时,必须按顺序链接。才能编译成功,顺序如下:
add_executable(test src/main.cpp)
target_link_libraries(test
${catkin_LIBRARIES}
${LIB_DIR_ARCH}/cpp-tbox/lib/libtbox_main.a
${LIB_DIR_ARCH}/cpp-tbox/lib/libtbox_log.a
${LIB_DIR_ARCH}/cpp-tbox/lib/libtbox_terminal.a
${LIB_DIR_ARCH}/cpp-tbox/lib/libtbox_network.a
${LIB_DIR_ARCH}/cpp-tbox/lib/libtbox_eventx.a
${LIB_DIR_ARCH}/cpp-tbox/lib/libtbox_event.a
${LIB_DIR_ARCH}/cpp-tbox/lib/libtbox_util.a
${LIB_DIR_ARCH}/cpp-tbox/lib/libtbox_base.a
-lpthread
-ldl
)

target_link_libraries增加 -Wl,--start-group 和-Wl,--end-group参数可以实现随意顺序链接
set(TBOX_LIB
${TBOX_LIB_PATH}/libtbox_terminal.a
${TBOX_LIB_PATH}/libtbox_network.a
${TBOX_LIB_PATH}/libtbox_log.a
${TBOX_LIB_PATH}/libtbox_util.a
${TBOX_LIB_PATH}/libtbox_base.a
${TBOX_LIB_PATH}/libtbox_main.a
${TBOX_LIB_PATH}/libtbox_alarm.a
${TBOX_LIB_PATH}/libtbox_coroutine.a
${TBOX_LIB_PATH}/libtbox_crypto.a
${TBOX_LIB_PATH}/libtbox_dbus.a
${TBOX_LIB_PATH}/libtbox_flow.a
${TBOX_LIB_PATH}/libtbox_eventx.a
${TBOX_LIB_PATH}/libtbox_http.a
${TBOX_LIB_PATH}/libtbox_jsonrpc.a
${TBOX_LIB_PATH}/libtbox_mqtt.a
${TBOX_LIB_PATH}/libtbox_event.a

)
target_link_libraries(${TARGETFILE}
-Wl,--start-group
pthread
dl
file
${crypto_LIB}
${TBOX_LIB}
-Wl,--end-group)