From 4e57416be9edd48c50a9631c74de3c3729724e61 Mon Sep 17 00:00:00 2001 From: baiyfcu Date: Fri, 27 May 2022 17:03:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dcmake=20generate=20export=20?= =?UTF-8?q?=E5=92=8C=20test=E5=B7=A5=E7=A8=8B=E5=85=88=E5=90=8E=E5=8F=98?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/CMakeLists.txt | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt index f3e55da9..713e7ae6 100644 --- a/api/CMakeLists.txt +++ b/api/CMakeLists.txt @@ -5,19 +5,20 @@ file(GLOB api_src_list include/*.h source/*.cpp source/*.h source/*.c) if (IOS) add_library(mk_api STATIC ${api_src_list}) target_link_libraries(mk_api ${LINK_LIB_LIST} jsoncpp) -else () - if (ENABLE_API_STATIC_LIB) - add_library(mk_api STATIC ${api_src_list}) - else () - add_library(mk_api SHARED ${api_src_list}) - endif () + return() +endif () - if (CMAKE_SYSTEM_NAME MATCHES "Linux") - target_link_libraries(mk_api -Wl,--start-group jsoncpp ${LINK_LIB_LIST} -Wl,--end-group) - else () - target_link_libraries(mk_api jsoncpp ${LINK_LIB_LIST}) - endif () - add_subdirectory(tests) +if (ENABLE_API_STATIC_LIB) + add_definitions(-DMediaKitApi_STATIC) + add_library(mk_api STATIC ${api_src_list}) +else () + add_library(mk_api SHARED ${api_src_list}) +endif () + +if (CMAKE_SYSTEM_NAME MATCHES "Linux") + target_link_libraries(mk_api -Wl,--start-group jsoncpp ${LINK_LIB_LIST} -Wl,--end-group) +else () + target_link_libraries(mk_api jsoncpp ${LINK_LIB_LIST}) endif () add_definitions(-DGENERATE_EXPORT) @@ -29,8 +30,8 @@ generate_export_header(mk_api EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/mk_export.h" ) -if (NOT IOS) - file(GLOB api_header_list include/*.h ${CMAKE_BINARY_DIR}/*.h) - install(FILES ${api_header_list} DESTINATION ${INSTALL_PATH_INCLUDE}) - install(TARGETS mk_api ARCHIVE DESTINATION ${INSTALL_PATH_LIB} LIBRARY DESTINATION ${INSTALL_PATH_LIB}) -endif () \ No newline at end of file +add_subdirectory(tests) + +file(GLOB api_header_list include/*.h ${CMAKE_BINARY_DIR}/*.h) +install(FILES ${api_header_list} DESTINATION ${INSTALL_PATH_INCLUDE}) +install(TARGETS mk_api ARCHIVE DESTINATION ${INSTALL_PATH_LIB} LIBRARY DESTINATION ${INSTALL_PATH_LIB}) \ No newline at end of file