CMakeLists.txt 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. cmake_minimum_required(VERSION 3.18)
  2. set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "10.0" CACHE STRING "Minimum iOS deployment version")
  3. set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING "Minimum OS X deployment version")
  4. project(webrtc
  5. VERSION 2.4.0
  6. LANGUAGES C CXX ASM
  7. )
  8. cmake_policy(SET CMP0076 NEW)
  9. # Enable unit testing
  10. enable_testing()
  11. # Define flags to determine the build target platform
  12. # Windows, Linux, macOS, iOS, Android
  13. if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
  14. set(Windows TRUE)
  15. endif()
  16. if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
  17. set(iOS TRUE)
  18. endif()
  19. if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  20. set(Linux TRUE)
  21. endif()
  22. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  23. set(macOS TRUE)
  24. endif()
  25. if(CMAKE_SYSTEM_NAME STREQUAL "Android")
  26. set(Android TRUE)
  27. endif()
  28. set(CMAKE_CXX_STANDARD 14)
  29. set(CMAKE_CXX_EXTENSIONS OFF)
  30. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  31. if(XCODE)
  32. if(${XCODE_VERSION} VERSION_GREATER_EQUAL 12.0.0 AND
  33. ${XCODE_VERSION} VERSION_LESS 11.0.0
  34. )
  35. message(FATAL_ERROR
  36. "The required Xcode version is 11.0 or higher and 12.0 or higher is not supported.")
  37. endif()
  38. endif()
  39. if(Linux)
  40. option(USE_CUSTOM_LIBCXX_STATIC "Use custom libc++" OFF)
  41. option(CUSTOM_LIBCXX_DIR "Set filepath for custom libc++" "${CMAKE_SOURCE_DIR}")
  42. if(USE_CUSTOM_LIBCXX_STATIC)
  43. add_compile_options(-nostdinc++)
  44. add_link_options(-static-libstdc++)
  45. include_directories("${CUSTOM_LIBCXX_DIR}/include/c++/v1/")
  46. set(CXX_LIBRARY "${CUSTOM_LIBCXX_DIR}/lib/libc++.a")
  47. set(CXXABI_LIBRARY "${CUSTOM_LIBCXX_DIR}/lib/libc++abi.a")
  48. endif()
  49. endif()
  50. # enable debug output
  51. set(CMAKE_VERBOSE_MAKEFILE ON)
  52. # set iterator debug level
  53. if(Windows)
  54. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_ITERATOR_DEBUG_LEVEL=0 /Zi /Od")
  55. endif()
  56. set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
  57. find_package(Threads REQUIRED)
  58. list(APPEND CMAKE_MODULE_PATH
  59. "${CMAKE_SOURCE_DIR}/cmake"
  60. )
  61. find_package(WebRTC REQUIRED)
  62. if(iOS OR macOS)
  63. find_package(Framework REQUIRED)
  64. endif()
  65. if(Windows OR Linux)
  66. find_package(CUDA REQUIRED)
  67. find_package(Vulkan REQUIRED)
  68. add_subdirectory(NvCodec)
  69. endif()
  70. add_subdirectory(WebRTCPlugin)
  71. add_subdirectory(WebRTCPluginTest)