Add an ability to replace some source files before building.

This commit is contained in:
Kirill Kirilenko 2022-10-03 15:43:17 +03:00
parent d667dab439
commit 0e08c8388a
3 changed files with 16 additions and 1 deletions

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.9)
cmake_minimum_required(VERSION 3.20)
set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING INTERNAL FORCE)
@ -35,6 +35,11 @@ if (MSVC)
patch_file(${WEBRTC_SOURCE_DIR}/build/config/win/BUILD.gn ":static_crt" ":dynamic_crt")
endif ()
# Copy all files from 'patches' directory to 'webrtc/src'
# For example, 'patches/api/foo.h' will be copied to 'webrtc/src/api/foo.h'
include(PatchSources)
patch_sources("${CMAKE_CURRENT_SOURCE_DIR}/patches" "${CMAKE_CURRENT_SOURCE_DIR}/webrtc/src")
include(AddWebRTCTarget)
add_webrtc_target(${WEBRTC_SOURCE_DIR} ${WEBRTC_BUILD_DIR})

10
cmake/PatchSources.cmake Normal file
View file

@ -0,0 +1,10 @@
function(patch_sources PATCH_DIR SOURCE_DIR)
file(GLOB_RECURSE PATCHED_SOURCES RELATIVE ${PATCH_DIR} ${PATCH_DIR}/*)
list(REMOVE_ITEM PATCHED_SOURCES ".gitkeep")
foreach (file ${PATCHED_SOURCES})
message(STATUS "Patching ${file}...")
set(destination "${SOURCE_DIR}/${file}")
cmake_path(GET destination PARENT_PATH dest_dir)
file(COPY ${PATCH_DIR}/${file} DESTINATION ${dest_dir})
endforeach ()
endfunction()

0
patches/.gitkeep Normal file
View file