2022-07-25 00:22:30 +08:00
|
|
|
|
# MIT License
|
|
|
|
|
#
|
|
|
|
|
# Copyright (c) 2016-2022 The ZLMediaKit project authors. All Rights Reserved.
|
|
|
|
|
#
|
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
# in the Software without restriction, including without limitation the rights
|
|
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
|
#
|
|
|
|
|
# The above copyright notice and this permission notice shall be included in all
|
|
|
|
|
# copies or substantial portions of the Software.
|
|
|
|
|
#
|
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
|
# SOFTWARE.
|
|
|
|
|
#
|
|
|
|
|
|
2022-05-26 20:30:43 +08:00
|
|
|
|
include(GenerateExportHeader)
|
2022-07-25 00:22:30 +08:00
|
|
|
|
file(GLOB API_SRC_LIST
|
|
|
|
|
include/*.h
|
|
|
|
|
source/*.c
|
|
|
|
|
source/*.cpp
|
|
|
|
|
source/*.h)
|
|
|
|
|
|
2022-10-06 12:33:48 +08:00
|
|
|
|
set(LINK_LIBRARIES ${MK_LINK_LIBRARIES})
|
2020-04-08 15:42:52 +08:00
|
|
|
|
|
2022-07-25 00:22:30 +08:00
|
|
|
|
set(COMPILE_DEFINITIONS ${MK_COMPILE_DEFINITIONS})
|
2022-11-03 10:51:49 +08:00
|
|
|
|
|
|
|
|
|
if (MSVC)
|
|
|
|
|
list(APPEND COMPILE_DEFINITIONS GENERATE_EXPORT)
|
|
|
|
|
endif ()
|
2022-05-28 09:48:19 +08:00
|
|
|
|
|
2022-07-25 00:22:30 +08:00
|
|
|
|
if(ENABLE_API_STATIC_LIB)
|
|
|
|
|
add_library(mk_api STATIC ${API_SRC_LIST})
|
|
|
|
|
list(APPEND COMPILE_DEFINITIONS MediaKitApi_STATIC)
|
2023-06-27 10:51:31 +08:00
|
|
|
|
elseif(IOS)
|
|
|
|
|
add_library(mk_api STATIC ${API_SRC_LIST})
|
2022-07-25 00:22:30 +08:00
|
|
|
|
else()
|
|
|
|
|
add_library(mk_api SHARED ${API_SRC_LIST})
|
|
|
|
|
endif()
|
2022-05-26 20:30:43 +08:00
|
|
|
|
|
2022-07-25 00:22:30 +08:00
|
|
|
|
target_compile_definitions(mk_api
|
|
|
|
|
PRIVATE ${COMPILE_DEFINITIONS})
|
|
|
|
|
target_include_directories(mk_api
|
|
|
|
|
PRIVATE
|
|
|
|
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
|
|
|
|
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
|
|
|
|
PUBLIC
|
2022-08-03 22:27:54 +08:00
|
|
|
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
|
2022-07-25 00:22:30 +08:00
|
|
|
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>")
|
|
|
|
|
|
|
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
|
|
|
target_link_libraries(mk_api -Wl,--start-group ${LINK_LIBRARIES} -Wl,--end-group)
|
2022-08-03 20:57:16 +08:00
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Android")
|
|
|
|
|
target_link_libraries(mk_api log -Wl,--start-group ${LINK_LIBRARIES} -Wl,--end-group)
|
2022-07-25 00:22:30 +08:00
|
|
|
|
else()
|
2022-10-06 12:33:48 +08:00
|
|
|
|
target_link_libraries(mk_api ${LINK_LIBRARIES})
|
2022-07-25 00:22:30 +08:00
|
|
|
|
endif()
|
2022-05-26 20:30:43 +08:00
|
|
|
|
|
|
|
|
|
generate_export_header(mk_api
|
2022-07-25 00:22:30 +08:00
|
|
|
|
EXPORT_MACRO_NAME API_EXPORT
|
|
|
|
|
BASE_NAME MK_API
|
|
|
|
|
STATIC_DEFINE MediaKitApi_STATIC
|
2022-08-03 22:27:54 +08:00
|
|
|
|
EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/mk_export.h")
|
2019-12-17 18:45:31 +08:00
|
|
|
|
|
2022-07-25 00:22:30 +08:00
|
|
|
|
file(GLOB API_HEADER_LIST include/*.h ${CMAKE_CURRENT_BINARY_DIR}/*.h)
|
|
|
|
|
install(FILES ${API_HEADER_LIST}
|
|
|
|
|
DESTINATION ${INSTALL_PATH_INCLUDE})
|
|
|
|
|
install(TARGETS mk_api
|
|
|
|
|
ARCHIVE DESTINATION ${INSTALL_PATH_LIB}
|
2023-02-28 23:00:59 +08:00
|
|
|
|
LIBRARY DESTINATION ${INSTALL_PATH_LIB}
|
|
|
|
|
RUNTIME DESTINATION ${INSTALL_PATH_RUNTIME})
|
2023-06-17 10:24:17 +08:00
|
|
|
|
|
2023-06-27 10:51:31 +08:00
|
|
|
|
# IOS 跳过测试代码
|
|
|
|
|
if(IOS)
|
|
|
|
|
return()
|
|
|
|
|
endif()
|
|
|
|
|
|
2023-06-17 10:24:17 +08:00
|
|
|
|
if (ENABLE_TESTS)
|
|
|
|
|
add_subdirectory(tests)
|
|
|
|
|
endif()
|