Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

6 месяцев назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # MIT License
  2. #
  3. # Copyright (c) 2016-2022 The ZLMediaKit project authors. All Rights Reserved.
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a copy
  6. # of this software and associated documentation files (the "Software"), to deal
  7. # in the Software without restriction, including without limitation the rights
  8. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. # copies of the Software, and to permit persons to whom the Software is
  10. # furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included in all
  13. # copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. # SOFTWARE.
  22. #
  23. set(LINK_LIBRARIES ${MK_LINK_LIBRARIES})
  24. find_package(PkgConfig QUIET)
  25. # 查找 SDL2 是否安装
  26. if(PKG_CONFIG_FOUND)
  27. pkg_check_modules(SDL2 QUIET IMPORTED_TARGET sdl2)
  28. if(SDL2_FOUND)
  29. list(APPEND LINK_LIBRARIES PkgConfig::SDL2)
  30. message(STATUS "found library: ${SDL2_LIBRARIES}")
  31. endif()
  32. else()
  33. find_package(SDL2 QUIET)
  34. if(SDL2_FOUND)
  35. include_directories(SYSTEM ${SDL2_INCLUDE_DIR})
  36. list(APPEND LINK_LIBRARIES ${SDL2_LIBRARY})
  37. message(STATUS "found library: ${SDL2_LIBRARY}")
  38. endif()
  39. endif()
  40. set(PLAYER_NAME "test_player")
  41. # 如果 ffmpeg/libavcodec ffmpeg/libavcodec SDL 都安装了则编译播放器
  42. if(NOT SDL2_FOUND)
  43. message(WARNING "${PLAYER_NAME} disabled, please install sdl2 ffmpeg/libavcodec ffmpeg/libavutil ffmpeg/libswresample")
  44. return()
  45. endif()
  46. message(STATUS "${PLAYER_NAME} enabled")
  47. aux_source_directory(. SRC_LIST)
  48. add_executable(${PLAYER_NAME} ${SRC_LIST})
  49. target_compile_definitions(${PLAYER_NAME}
  50. PRIVATE ${MK_COMPILE_DEFINITIONS})
  51. target_compile_options(${PLAYER_NAME}
  52. PRIVATE ${COMPILE_OPTIONS_DEFAULT})
  53. # TODO: 统一参数?
  54. if(MSVC)
  55. set_target_properties(${PLAYER_NAME} PROPERTIES LINK_FLAGS "/SAFESEH:NO /SUBSYSTEM:WINDOWS")
  56. endif()
  57. if(CMAKE_SYSTEM_NAME MATCHES "Linux")
  58. target_link_libraries(${PLAYER_NAME} -Wl,--start-group ${LINK_LIBRARIES} -Wl,--end-group)
  59. else()
  60. target_link_libraries(${PLAYER_NAME} ${LINK_LIBRARIES})
  61. endif()