优化CMakeList, 完善iOS下编译配置 (#2578)

1、调整 json 的源码引入,外部可以引入 json/json.h 使用;
2、针对 iOS 工程调整 cmake 配置,解决 iOS 环境下mk_util.h 找不到问题;同时在 iOS 工程中引入 MediaServer 静态库;
This commit is contained in:
朱如洪 2023-06-27 10:51:31 +08:00 committed by GitHub
parent 6cd9e15cb8
commit c530f281c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 14 deletions

View File

@ -24,7 +24,11 @@
############################################################################## ##############################################################################
# jsoncpp # 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}) add_library(jsoncpp STATIC ${JSONCPP_SRC_LIST})
target_compile_options(jsoncpp target_compile_options(jsoncpp
PRIVATE ${COMPILE_OPTIONS_DEFAULT}) PRIVATE ${COMPILE_OPTIONS_DEFAULT})

View File

@ -449,11 +449,6 @@ if(ENABLE_API)
add_subdirectory(api) add_subdirectory(api)
endif() endif()
# IOS
if(IOS)
return()
endif()
############################################################################## ##############################################################################
if(ENABLE_PLAYER AND ENABLE_FFMPEG) if(ENABLE_PLAYER AND ENABLE_FFMPEG)
@ -470,6 +465,11 @@ if(ENABLE_SERVER_LIB)
set(MK_LINK_LIBRARIES ${MK_LINK_LIBRARIES} PARENT_SCOPE) set(MK_LINK_LIBRARIES ${MK_LINK_LIBRARIES} PARENT_SCOPE)
endif() endif()
# IOS
if(IOS)
return()
endif()
#cppdemo #cppdemo
if (ENABLE_TESTS) if (ENABLE_TESTS)
add_subdirectory(tests) add_subdirectory(tests)

View File

@ -30,13 +30,6 @@ file(GLOB API_SRC_LIST
set(LINK_LIBRARIES ${MK_LINK_LIBRARIES}) 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}) set(COMPILE_DEFINITIONS ${MK_COMPILE_DEFINITIONS})
if (MSVC) if (MSVC)
@ -46,6 +39,8 @@ endif ()
if(ENABLE_API_STATIC_LIB) if(ENABLE_API_STATIC_LIB)
add_library(mk_api STATIC ${API_SRC_LIST}) add_library(mk_api STATIC ${API_SRC_LIST})
list(APPEND COMPILE_DEFINITIONS MediaKitApi_STATIC) list(APPEND COMPILE_DEFINITIONS MediaKitApi_STATIC)
elseif(IOS)
add_library(mk_api STATIC ${API_SRC_LIST})
else() else()
add_library(mk_api SHARED ${API_SRC_LIST}) add_library(mk_api SHARED ${API_SRC_LIST})
endif() endif()
@ -82,6 +77,11 @@ install(TARGETS mk_api
LIBRARY DESTINATION ${INSTALL_PATH_LIB} LIBRARY DESTINATION ${INSTALL_PATH_LIB}
RUNTIME DESTINATION ${INSTALL_PATH_RUNTIME}) RUNTIME DESTINATION ${INSTALL_PATH_RUNTIME})
# IOS
if(IOS)
return()
endif()
if (ENABLE_TESTS) if (ENABLE_TESTS)
add_subdirectory(tests) add_subdirectory(tests)
endif() endif()

View File

@ -38,7 +38,13 @@ if(ENABLE_SERVER_LIB)
return() return()
endif() endif()
# IOS
if(IOS)
add_library(MediaServer STATIC ${MediaServer_SRC_LIST})
else()
add_executable(MediaServer ${MediaServer_SRC_LIST}) add_executable(MediaServer ${MediaServer_SRC_LIST})
endif()
target_compile_definitions(MediaServer target_compile_definitions(MediaServer
PRIVATE ${COMPILE_DEFINITIONS}) PRIVATE ${COMPILE_DEFINITIONS})
target_compile_options(MediaServer target_compile_options(MediaServer