From c530f281c3aceddae29bdda0ff78af74433dad51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=A6=82=E6=B4=AA?= Date: Tue, 27 Jun 2023 10:51:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96CMakeList,=20=E5=AE=8C?= =?UTF-8?q?=E5=96=84iOS=E4=B8=8B=E7=BC=96=E8=AF=91=E9=85=8D=E7=BD=AE=20(#2?= =?UTF-8?q?578)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1、调整 json 的源码引入,外部可以引入 json/json.h 使用; 2、针对 iOS 工程调整 cmake 配置,解决 iOS 环境下mk_util.h 找不到问题;同时在 iOS 工程中引入 MediaServer 静态库; --- 3rdpart/CMakeLists.txt | 6 +++++- CMakeLists.txt | 10 +++++----- api/CMakeLists.txt | 14 +++++++------- server/CMakeLists.txt | 8 +++++++- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/3rdpart/CMakeLists.txt b/3rdpart/CMakeLists.txt index 44e3a551..07d5d388 100644 --- a/3rdpart/CMakeLists.txt +++ b/3rdpart/CMakeLists.txt @@ -24,7 +24,11 @@ ############################################################################## # jsoncpp -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/jsoncpp/src/lib_json JSONCPP_SRC_LIST) +file(GLOB JSONCPP_SRC_LIST + ${CMAKE_CURRENT_SOURCE_DIR}/jsoncpp/include/json/*.h + ${CMAKE_CURRENT_SOURCE_DIR}/jsoncpp/src/lib_json/*.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/jsoncpp/src/lib_json/*.h) + add_library(jsoncpp STATIC ${JSONCPP_SRC_LIST}) target_compile_options(jsoncpp PRIVATE ${COMPILE_OPTIONS_DEFAULT}) diff --git a/CMakeLists.txt b/CMakeLists.txt index b1fb9bb8..66689d9c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -449,11 +449,6 @@ if(ENABLE_API) add_subdirectory(api) endif() -# IOS 不编译可执行程序 -if(IOS) - return() -endif() - ############################################################################## if(ENABLE_PLAYER AND ENABLE_FFMPEG) @@ -470,6 +465,11 @@ if(ENABLE_SERVER_LIB) set(MK_LINK_LIBRARIES ${MK_LINK_LIBRARIES} PARENT_SCOPE) endif() +# IOS 不编译可执行程序 +if(IOS) + return() +endif() + #cpp测试demo程序 if (ENABLE_TESTS) add_subdirectory(tests) diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt index 851bb3c5..102a03a6 100644 --- a/api/CMakeLists.txt +++ b/api/CMakeLists.txt @@ -30,13 +30,6 @@ file(GLOB API_SRC_LIST set(LINK_LIBRARIES ${MK_LINK_LIBRARIES}) -if(IOS) - add_library(mk_api STATIC ${API_SRC_LIST}) - target_link_libraries(mk_api - PRIVATE ${LINK_LIBRARIES}) - return() -endif () - set(COMPILE_DEFINITIONS ${MK_COMPILE_DEFINITIONS}) if (MSVC) @@ -46,6 +39,8 @@ endif () if(ENABLE_API_STATIC_LIB) add_library(mk_api STATIC ${API_SRC_LIST}) list(APPEND COMPILE_DEFINITIONS MediaKitApi_STATIC) +elseif(IOS) + add_library(mk_api STATIC ${API_SRC_LIST}) else() add_library(mk_api SHARED ${API_SRC_LIST}) endif() @@ -82,6 +77,11 @@ install(TARGETS mk_api LIBRARY DESTINATION ${INSTALL_PATH_LIB} RUNTIME DESTINATION ${INSTALL_PATH_RUNTIME}) +# IOS 跳过测试代码 +if(IOS) + return() +endif() + if (ENABLE_TESTS) add_subdirectory(tests) endif() diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index f0dea82b..748cb48a 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -38,7 +38,13 @@ if(ENABLE_SERVER_LIB) return() endif() -add_executable(MediaServer ${MediaServer_SRC_LIST}) +# IOS 不编译可执行程序,只做依赖库 +if(IOS) + add_library(MediaServer STATIC ${MediaServer_SRC_LIST}) +else() + add_executable(MediaServer ${MediaServer_SRC_LIST}) +endif() + target_compile_definitions(MediaServer PRIVATE ${COMPILE_DEFINITIONS}) target_compile_options(MediaServer