Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

CMakeLists.txt 2.8KB

před 8 měsíci
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. include(GenerateExportHeader)
  24. file(GLOB API_SRC_LIST
  25. include/*.h
  26. source/*.c
  27. source/*.cpp
  28. source/*.h)
  29. set(LINK_LIBRARIES ${MK_LINK_LIBRARIES})
  30. if(IOS)
  31. add_library(mk_api STATIC ${API_SRC_LIST})
  32. target_link_libraries(mk_api
  33. PRIVATE ${LINK_LIBRARIES})
  34. return()
  35. endif ()
  36. set(COMPILE_DEFINITIONS ${MK_COMPILE_DEFINITIONS})
  37. if (MSVC)
  38. list(APPEND COMPILE_DEFINITIONS GENERATE_EXPORT)
  39. endif ()
  40. if(ENABLE_API_STATIC_LIB)
  41. add_library(mk_api STATIC ${API_SRC_LIST})
  42. list(APPEND COMPILE_DEFINITIONS MediaKitApi_STATIC)
  43. else()
  44. add_library(mk_api SHARED ${API_SRC_LIST})
  45. endif()
  46. target_compile_definitions(mk_api
  47. PRIVATE ${COMPILE_DEFINITIONS})
  48. target_include_directories(mk_api
  49. PRIVATE
  50. "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
  51. "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
  52. PUBLIC
  53. "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
  54. "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>")
  55. if(CMAKE_SYSTEM_NAME MATCHES "Linux")
  56. target_link_libraries(mk_api -Wl,--start-group ${LINK_LIBRARIES} -Wl,--end-group)
  57. elseif(CMAKE_SYSTEM_NAME MATCHES "Android")
  58. target_link_libraries(mk_api log -Wl,--start-group ${LINK_LIBRARIES} -Wl,--end-group)
  59. else()
  60. target_link_libraries(mk_api ${LINK_LIBRARIES})
  61. endif()
  62. generate_export_header(mk_api
  63. EXPORT_MACRO_NAME API_EXPORT
  64. BASE_NAME MK_API
  65. STATIC_DEFINE MediaKitApi_STATIC
  66. EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/mk_export.h")
  67. add_subdirectory(tests)
  68. file(GLOB API_HEADER_LIST include/*.h ${CMAKE_CURRENT_BINARY_DIR}/*.h)
  69. install(FILES ${API_HEADER_LIST}
  70. DESTINATION ${INSTALL_PATH_INCLUDE})
  71. install(TARGETS mk_api
  72. ARCHIVE DESTINATION ${INSTALL_PATH_LIB}
  73. LIBRARY DESTINATION ${INSTALL_PATH_LIB})