From 0eca329dbacb7b497e66c76989c2dc76b03c4034 Mon Sep 17 00:00:00 2001 From: baiyfcu Date: Fri, 26 Jul 2024 09:55:33 +0800 Subject: [PATCH] =?UTF-8?q?ZLM=20CXX=E6=B7=BB=E5=8A=A0exprt=E6=96=87?= =?UTF-8?q?=E4=BB=B6,ext-codec=E5=BC=95=E7=94=A8zlm=E4=B8=AD=E5=AE=8F?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=EF=BC=8C=E5=AE=8C=E5=96=84install=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=96=87=E4=BB=B6=E5=AE=89=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3rdpart/CMakeLists.txt | 15 ++++++++----- 3rdpart/ZLToolKit | 2 +- api/include/mk_common.h | 2 +- ext-codec/CMakeLists.txt | 15 ++++++++++--- src/CMakeLists.txt | 47 ++++++++++++++++++++++++++++------------ src/Common/macros.h | 22 +++++++++++++------ 6 files changed, 72 insertions(+), 31 deletions(-) diff --git a/3rdpart/CMakeLists.txt b/3rdpart/CMakeLists.txt index 16212594..d4eb29b7 100644 --- a/3rdpart/CMakeLists.txt +++ b/3rdpart/CMakeLists.txt @@ -237,9 +237,14 @@ endif() # 未在使用 if(ENABLE_CXX_API) # 保留目录结构 - #install(DIRECTORY ${ToolKit_ROOT}/ - # DESTINATION ${INSTALL_PATH_INCLUDE}/ZLToolKit - # REGEX "(.*[.](md|cpp)|win32)$" EXCLUDE) - #install(TARGETS zltoolkit - # DESTINATION ${INSTALL_PATH_LIB}) + install(DIRECTORY ${ToolKit_ROOT}/src/ + DESTINATION ${INSTALL_PATH_INCLUDE}/ZLToolKit + REGEX "(.*[.](md|cpp)|win32)$" EXCLUDE) + if(ENABLE_CXX_API) + install(TARGETS zltoolkit + DESTINATION ${INSTALL_PATH_BIN}) + else() + install(TARGETS zltoolkit + DESTINATION ${INSTALL_PATH_LIB}) + endif() endif() diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit index 9c5292f4..fdd3450f 160000 --- a/3rdpart/ZLToolKit +++ b/3rdpart/ZLToolKit @@ -1 +1 @@ -Subproject commit 9c5292f4f5c7fe36794c9b33d24c4b95e932f114 +Subproject commit fdd3450fc6bee60f8fb16ac4fd272c54d6b27238 diff --git a/api/include/mk_common.h b/api/include/mk_common.h index c2bf43bf..68b803b0 100755 --- a/api/include/mk_common.h +++ b/api/include/mk_common.h @@ -30,7 +30,7 @@ #if defined(_WIN32) && defined(_MSC_VER) # if !defined(GENERATE_EXPORT) -# if defined(MediaKitApi_EXPORTS) +# if defined(mk_api_EXPORTS) # define API_EXPORT __declspec(dllexport) # else # define API_EXPORT __declspec(dllimport) diff --git a/ext-codec/CMakeLists.txt b/ext-codec/CMakeLists.txt index 9fd9cdb5..58fa6eb2 100644 --- a/ext-codec/CMakeLists.txt +++ b/ext-codec/CMakeLists.txt @@ -23,9 +23,6 @@ set(COMPILE_DEFINITIONS) set(INCLUDE_DIRECTORIES) -# for zlm -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../3rdpart/ZLToolKit/src) file(GLOB EXT_SRC_LIST ${CMAKE_CURRENT_SOURCE_DIR}/*.c @@ -38,9 +35,21 @@ add_library(ZLMediaKit::ext-codec ALIAS ext-codec) target_compile_options(ext-codec PRIVATE ${COMPILE_OPTIONS_DEFAULT}) target_compile_definitions(ext-codec PUBLIC ${COMPILE_DEFINITIONS}) +target_compile_definitions(ext-codec PRIVATE ${MK_COMPILE_DEFINITIONS}) #target_link_libraries(ext-codec PRIVATE ZLMediaKit::MediaKit ZLMediaKit::ToolKit ${LINK_LIBRARIES}) +# for zlm +target_include_directories(ext-codec PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src ${CMAKE_CURRENT_SOURCE_DIR}/../3rdpart/ZLToolKit/src) + +set(MediaServer_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../3rdpart/media-server") +set(MediaServer_FLV_ROOT ${MediaServer_ROOT}/libflv) +target_include_directories(ext-codec + PRIVATE + "$" + PUBLIC + "$") + target_include_directories(ext-codec PRIVATE "$" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 53b762b2..510cb422 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,6 +21,8 @@ # SOFTWARE. # +include(GenerateExportHeader) + file(GLOB MediaKit_SRC_LIST ${CMAKE_CURRENT_SOURCE_DIR}/*/*.c ${CMAKE_CURRENT_SOURCE_DIR}/*/*.cpp @@ -31,7 +33,12 @@ if(USE_SOLUTION_FOLDERS AND (NOT GROUP_BY_EXPLORER)) set_file_group("${CMAKE_CURRENT_SOURCE_DIR}" ${MediaKit_SRC_LIST}) endif() -if(ENABLE_CXX_API) +if(NOT ENABLE_CXX_API OR IOS) + # 添加库 + add_library(zlmediakit STATIC ${MediaKit_SRC_LIST}) + add_library(ZLMediaKit::MediaKit ALIAS zlmediakit) + list(APPEND COMPILE_DEFINITIONS MediaKit_STATIC) +else() # 在 Windows 下启用导出所有符号的选项 if(WIN32) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) @@ -46,10 +53,6 @@ if(ENABLE_CXX_API) set_target_properties(zlmediakit PROPERTIES OUTPUT_NAME zlmediakit # 输出的 DLL 文件名 ) -else () - # 添加库 - add_library(zlmediakit STATIC ${MediaKit_SRC_LIST}) - add_library(ZLMediaKit::MediaKit ALIAS zlmediakit) endif () set(LINK_LIBRARIES ${MK_LINK_LIBRARIES}) @@ -63,19 +66,35 @@ target_compile_options(zlmediakit target_link_libraries(zlmediakit PUBLIC ${LINK_LIBRARIES}) target_include_directories(zlmediakit - PRIVATE - "$" - PUBLIC - "$") + PRIVATE + "$" + "$" + + PUBLIC + "$" + "$" +) update_cached_list(MK_LINK_LIBRARIES ZLMediaKit::MediaKit) + +generate_export_header(zlmediakit + EXPORT_MACRO_NAME MK_EXPORT + BASE_NAME MK_CXX + STATIC_DEFINE MediaKit_STATIC + EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/mk_cxx_export.h") + # 未在使用 if(ENABLE_CXX_API) # 保留目录结构 - #install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - # DESTINATION ${INSTALL_PATH_INCLUDE}/ZLMediaKit - # REGEX ".*[.](md|cpp)$" EXCLUDE) - #install(TARGETS zlmediakit - # DESTINATION ${INSTALL_PATH_LIB}) + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${INSTALL_PATH_INCLUDE}/ZLMediaKit + REGEX ".*[.](md|cpp)$" EXCLUDE) + if(ENABLE_CXX_API) + install(TARGETS zlmediakit + DESTINATION ${INSTALL_PATH_BIN}) + else() + install(TARGETS zlmediakit + DESTINATION ${INSTALL_PATH_LIB}) + endif() endif () diff --git a/src/Common/macros.h b/src/Common/macros.h index 38cd0acb..6b75eebf 100644 --- a/src/Common/macros.h +++ b/src/Common/macros.h @@ -79,20 +79,28 @@ extern void Assert_Throw(int failed, const char *exp, const char *func, const ch } #endif -#if defined(ENABLE_CXX_API) + +#if defined(GENERATE_EXPORT) +#include "mk_cxx_export.h" +#endif + #if defined(_WIN32) && defined(_MSC_VER) -# if defined(MediaKit_EXPORTS) +# define API_CALL __cdecl +#else +# define API_CALL +#endif + +#if defined(_WIN32) && defined(_MSC_VER) +# if !defined(GENERATE_EXPORT) +# if defined(zlmediakit_EXPORTS) # define MK_EXPORT __declspec(dllexport) # else # define MK_EXPORT __declspec(dllimport) # endif -#else +# endif +#elif !defined(GENERATE_EXPORT) # define MK_EXPORT __attribute__((visibility("default"))) #endif -#else -# define MK_EXPORT -#endif - namespace mediakit {