123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422 |
- add_library(WebRTCLib STATIC)
- target_sources(WebRTCLib
- PRIVATE
- Context.cpp
- Context.h
- CreateSessionDescriptionObserver.cpp
- CreateSessionDescriptionObserver.h
- DataChannelObject.cpp
- DataChannelObject.h
- DummyAudioDevice.cpp
- DummyAudioDevice.h
- AudioTrackSinkAdapter.h
- AudioTrackSinkAdapter.cpp
- Logger.cpp
- MediaStreamObserver.cpp
- MediaStreamObserver.h
- pch.cpp
- pch.h
- PeerConnectionObject.cpp
- PeerConnectionObject.h
- PeerConnectionStatsCollectorCallback.cpp
- PeerConnectionStatsCollectorCallback.h
- PlatformBase.h
- ProfilerMarkerFactory.cpp
- ProfilerMarkerFactory.h
- SetSessionDescriptionObserver.cpp
- SetSessionDescriptionObserver.h
- ScopedProfiler.h
- ScopedProfiler.cpp
- targetver.h
- UnityAudioDecoderFactory.cpp
- UnityAudioDecoderFactory.h
- UnityAudioEncoderFactory.cpp
- UnityAudioEncoderFactory.h
- UnityAudioTrackSource.cpp
- UnityAudioTrackSource.h
- UnityProfilerInterfaceFunctions.cpp
- UnityProfilerInterfaceFunctions.h
- UnityVideoDecoderFactory.cpp
- UnityVideoDecoderFactory.h
- UnityVideoEncoderFactory.cpp
- UnityVideoEncoderFactory.h
- UnityVideoRenderer.cpp
- UnityVideoRenderer.h
- UnityVideoTrackSource.cpp
- UnityVideoTrackSource.h
- WebRTCMacros.h
- WebRTCPlugin.h
- UnityLogStream.h
- UnityLogStream.cpp
- VideoFrame.cpp
- VideoFrame.h
- VideoFrameAdapter.cpp
- VideoFrameAdapter.h
- VideoFrameScheduler.cpp
- VideoFrameScheduler.h
- VideoFrameUtil.cpp
- VideoFrameUtil.h
- GpuMemoryBuffer.cpp
- GpuMemoryBuffer.h
- GpuMemoryBufferPool.cpp
- GpuMemoryBufferPool.h
- )
- if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- # Visual Studio Generator has not been supported supression warnings of external headers yet.
- # https://gitlab.kitware.com/cmake/cmake/-/issues/17904
- if(CMAKE_GENERATOR MATCHES "Visual Studio")
- set(VISUALSTUDIO_GENERATOR 1)
- else()
- set(VISUALSTUDIO_GENERATOR 0)
- endif()
- target_compile_options(WebRTCLib
- PUBLIC
- $<$<NOT:${VISUALSTUDIO_GENERATOR}>:-Werror>
- $<${VISUALSTUDIO_GENERATOR}:-Wno-c++98-compat>
- $<${VISUALSTUDIO_GENERATOR}:-Wno-c++98-compat-pedantic>
- -Wall
- -Wextra
- -Wformat=2
- -Wno-unused-parameter
- )
- endif()
- target_compile_definitions(WebRTCLib
- PUBLIC
- $<$<CONFIG:Debug>:DEBUG>
- )
- set_target_properties(WebRTCLib
- PROPERTIES
- CXX_VISIBILITY_PRESET hidden
- VISIBILITY_INLINES_HIDDEN ON
- )
- if(iOS OR macOS)
- target_sources(WebRTCLib
- PRIVATE
- ../libcxx/debug.cpp
- )
- else()
- target_sources(WebRTCLib
- PRIVATE
- UnityVulkanInterfaceFunctions.cpp
- UnityVulkanInterfaceFunctions.h
- )
- endif()
- if(Android)
- add_subdirectory(Android)
- endif()
- add_subdirectory(Codec)
- add_subdirectory(GraphicsDevice)
- if(Windows)
- # Force to always compile with W4
- if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
- string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
- else()
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
- endif()
- # Replace /GR option to disable RTTI
- foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
- CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
- string(REPLACE /GR /GR- "${flag_var}" "${${flag_var}}")
- endforeach()
- endif()
- if(Windows)
- # Use precompiled header
- set(CMAKE_CXX_FLAGS
- "${CMAKE_CXX_FLAGS} /Yu /Yupch.h")
- set(PROJECT_BINARY_DIR
- "${CMAKE_SOURCE_DIR}/../Runtime/Plugins/x86_64")
- target_compile_definitions(WebRTCLib
- PUBLIC
- WEBRTC_WIN
- NOMINMAX
- VK_NO_PROTOTYPES
- )
- target_link_libraries(WebRTCLib
- PRIVATE
- ${WEBRTC_LIBRARY}
- ${Vulkan_LIBRARY}
- ${CUDA_CUDA_LIBRARY}
- ${NVCODEC_LIBRARIES}
- d3d11
- winmm
- Secur32
- Msdmo
- Dmoguids
- wmcodecdspuuid
- Strmiids
- )
- target_include_directories(WebRTCLib
- SYSTEM
- PUBLIC
- ${CUDA_INCLUDE_DIRS}
- ${Vulkan_INCLUDE_DIR}
- ${NVCODEC_INCLUDE_DIR}
- )
- # Select runtime library (MT, MTD) on windows platform
- set_target_properties(WebRTCLib
- PROPERTIES
- MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
- )
- # Creare precompiled header
- set_source_files_properties(pch.cpp
- PROPERTIES
- COMPILE_FLAGS "/Yc /Ycpch.h"
- )
- elseif(macOS)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -x objective-c")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-lto -fno-rtti")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -x objective-c++")
- set(PROJECT_BINARY_DIR
- "${CMAKE_SOURCE_DIR}/../Runtime/Plugins/macOS")
- target_compile_definitions(WebRTCLib
- PUBLIC
- WEBRTC_MAC
- WEBRTC_POSIX
- )
- target_link_libraries(WebRTCLib
- PRIVATE
- ${WEBRTC_LIBRARY}
- ${FRAMEWORK_LIBS}
- )
- target_include_directories(WebRTCLib
- SYSTEM
- PUBLIC
- ${WEBRTC_OBJC_INCLUDE_DIR}
- )
- set_target_properties(WebRTCLib
- PROPERTIES
- LINK_FLAGS "-ObjC"
- )
- elseif(Linux)
- set(PROJECT_BINARY_DIR "${CMAKE_SOURCE_DIR}/../Runtime/Plugins/x86_64")
- set(GLAD_SOURCES_DIR "${CMAKE_SOURCE_DIR}/glad")
- add_subdirectory("${GLAD_SOURCES_DIR}/cmake" glad_cmake)
- glad_add_library(glad_gl_core_46 REPRODUCIBLE STATIC LOADER API gl:core=4.6)
- glad_add_library(glad_vulkan_11 REPRODUCIBLE STATIC LOADER API vulkan=1.1)
- glad_add_library(glad_glx_14 REPRODUCIBLE STATIC LOADER API glx=1.4)
- set_target_properties(glad_gl_core_46
- PROPERTIES
- POSITION_INDEPENDENT_CODE ON
- )
- set_target_properties(glad_vulkan_11
- PROPERTIES
- POSITION_INDEPENDENT_CODE ON
- )
- set_target_properties(glad_glx_14
- PROPERTIES
- POSITION_INDEPENDENT_CODE ON
- )
- target_link_libraries(glad_glx_14
- PUBLIC
- glad_gl_core_46
- )
- find_package(PkgConfig REQUIRED)
- pkg_check_modules(GLIB REQUIRED glib-2.0)
- target_compile_definitions(WebRTCLib
- PUBLIC
- WEBRTC_LINUX
- WEBRTC_POSIX
- VK_NO_PROTOTYPES
- )
- target_link_libraries(WebRTCLib
- PUBLIC
- NvCodec
- glad_gl_core_46
- glad_vulkan_11
- glad_glx_14
- ${WEBRTC_LIBRARY}
- ${GLIB_LIBRARIES}
- ${CXX_LIBRARY}
- ${CXXABI_LIBRARY}
- )
- target_include_directories(WebRTCLib
- SYSTEM
- PUBLIC
- ${CUDA_INCLUDE_DIRS}
- glad_gl_core_46
- glad_vulkan_11
- glad_glx_14
- ${NVCODEC_INCLUDE_DIR}
- )
- # enable -fPIC option
- set_target_properties(WebRTCLib
- PROPERTIES
- POSITION_INDEPENDENT_CODE ON
- )
- elseif(iOS)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -x objective-c -fembed-bitcode")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-lto -fno-rtti -fembed-bitcode")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -x objective-c++")
- set(PROJECT_BINARY_DIR
- "${CMAKE_SOURCE_DIR}/../Runtime/Plugins/iOS"
- )
- target_compile_definitions(WebRTCLib
- PUBLIC
- WEBRTC_IOS
- WEBRTC_MAC
- WEBRTC_POSIX
- )
- target_include_directories(WebRTCLib
- SYSTEM
- PUBLIC
- ${WEBRTC_OBJC_INCLUDE_DIR}
- )
- target_link_libraries(WebRTCLib
- PRIVATE
- ${WEBRTC_LIBRARY}
- ${FRAMEWORK_LIBS}
- )
- set_target_properties(WebRTCLib
- PROPERTIES
- LINK_FLAGS "-ObjC"
- )
- elseif(Android)
- target_compile_definitions(WebRTCLib
- PUBLIC
- WEBRTC_ANDROID
- WEBRTC_POSIX
- VK_NO_PROTOTYPES
- )
- target_link_libraries(WebRTCLib
- PRIVATE
- ${WEBRTC_LIBRARY}
- log
- OpenSLES
- GLESv3
- EGL
- )
- target_compile_options(WebRTCLib
- PUBLIC
- -fno-lto -fno-rtti
- )
- # Linker excludes unused symbols from the shared library
- # when linking the archive file (libwebrtc.a).
- file(READ "${CMAKE_SOURCE_DIR}/tools/android/jni_symbols.txt" JNI_SYMBOLS)
- string(REPLACE "\n" ";" JNI_SYMBOLS ${JNI_SYMBOLS})
- list(TRANSFORM JNI_SYMBOLS PREPEND "-Wl,--require-defined=")
- target_link_options(WebRTCLib
- PUBLIC
- ${JNI_SYMBOLS}
- )
- set(PROJECT_BINARY_DIR
- "${CMAKE_SOURCE_DIR}/../Runtime/Plugins/Android"
- )
- endif()
- target_include_directories(WebRTCLib
- SYSTEM
- PUBLIC
- ${CMAKE_SOURCE_DIR}/unity/include
- ${WEBRTC_INCLUDE_DIR}
- )
- target_include_directories(WebRTCLib
- PUBLIC
- .
- )
- add_library(WebRTCPlugin SHARED)
- set_target_properties(WebRTCPlugin
- PROPERTIES
- CXX_VISIBILITY_PRESET hidden
- VISIBILITY_INLINES_HIDDEN ON
- )
- if(iOS)
- set_target_properties(WebRTCPlugin
- PROPERTIES
- FRAMEWORK TRUE
- )
- endif()
- if(Windows)
- # link delayimp.lib to use delayload when building with Clang on Windows.
- target_link_libraries(WebRTCPlugin
- PRIVATE
- WebRTCLib
- delayimp.lib
- )
- else()
- target_link_libraries(WebRTCPlugin
- PRIVATE
- WebRTCLib
- )
- endif()
- target_sources(WebRTCPlugin
- PRIVATE
- pch.cpp
- pch.h
- WebRTCPlugin.cpp
- WebRTCPlugin.h
- UnityRenderEvent.cpp
- )
- # rename dll/framework filename
- set_target_properties(WebRTCPlugin
- PROPERTIES
- OUTPUT_NAME webrtc
- RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR}
- RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}
- LIBRARY_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR}
- LIBRARY_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}
- )
- if(Windows)
- # Set linker option
- set_target_properties(WebRTCPlugin
- PROPERTIES
- LINK_FLAGS "/SUBSYSTEM:WINDOWS -delayload:nvcuda.dll -delayload:nvEncodeAPI64.dll -delayload:nvcuvid.dll"
- MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
- )
- elseif(macOS)
- set_target_properties(WebRTCPlugin
- PROPERTIES
- LINK_FLAGS "-ObjC"
- )
- elseif(iOS)
- #
- # Build Setting Reference
- # https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html
- #
- set_target_properties(WebRTCPlugin
- PROPERTIES
- LINK_FLAGS "-ObjC"
- MACOSX_FRAMEWORK_IDENTIFIER "com.unity.webrtc"
- MACOSX_FRAMEWORK_BUNDLE_VERSION ${CMAKE_PROJECT_VERSION}
- MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${CMAKE_PROJECT_VERSION}
- XCODE_ATTRIBUTE_SKIP_INSTALL "NO"
- XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
- XCODE_ATTRIBUTE_STRIP_STYLE non-global
- XCODE_ATTRIBUTE_STRIP_INSTALLED_PRODUCT $<IF:$<CONFIG:Debug>,NO,YES>
- XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN $<IF:$<CONFIG:Debug>,NO,YES>
- )
- endif()
|