diff --git a/CMakeLists.txt b/CMakeLists.txt index da5bf749..36a62547 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,7 @@ option(BUILD_FFMPEG_VULKAN_PATCHES "Apply FFmpeg Vulkan patches" ON) # common includes include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/apply_git_patch.cmake) +include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/git_fetch_tags.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/unix_path.cmake) # CPM diff --git a/cmake/ffmpeg/_main.cmake b/cmake/ffmpeg/_main.cmake index 22cbad58..95aaadad 100644 --- a/cmake/ffmpeg/_main.cmake +++ b/cmake/ffmpeg/_main.cmake @@ -1,12 +1,3 @@ -# x265.pc will not be installed if their cmake cannot detect the latest tag -# SVT-AV1 cannot determine version if the git history is not available -foreach(repo "x265_git" "SVT-AV1") - execute_process( - COMMAND git -C "${CMAKE_CURRENT_SOURCE_DIR}/third-party/FFmpeg/${repo}" fetch --tags --depth=1 - COMMAND_ERROR_IS_FATAL ANY - ) -endforeach() - # the destination directory needs to be same level down as the original source directory file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/third-party/FFmpeg DESTINATION ${CMAKE_CURRENT_BINARY_DIR} PATTERN "Vulkan-Loader/tests" EXCLUDE) # vulkan loader test files contain emojis in file names which can fail diff --git a/cmake/ffmpeg/svt_av1.cmake b/cmake/ffmpeg/svt_av1.cmake index 63525fc2..9f66f200 100644 --- a/cmake/ffmpeg/svt_av1.cmake +++ b/cmake/ffmpeg/svt_av1.cmake @@ -1,3 +1,6 @@ +# SVT-AV1 cannot determine version if the git history is not available +GIT_FETCH_TAGS("third-party/FFmpeg/SVT-AV1") + set(SVT_AV1_GENERATED_SRC_PATH ${CMAKE_CURRENT_BINARY_DIR}/FFmpeg/SVT-AV1) if(BUILD_FFMPEG_ALL_PATCHES OR BUILD_FFMPEG_SVT_AV1_PATCHES) diff --git a/cmake/ffmpeg/x265.cmake b/cmake/ffmpeg/x265.cmake index 366a12a2..5291cf1b 100644 --- a/cmake/ffmpeg/x265.cmake +++ b/cmake/ffmpeg/x265.cmake @@ -1,3 +1,6 @@ +# x265.pc will not be installed if their cmake cannot detect the latest tag +GIT_FETCH_TAGS("third-party/FFmpeg/x265_git") + set(X265_GENERATED_SRC_PATH ${CMAKE_CURRENT_BINARY_DIR}/FFmpeg/x265_git) file(GLOB X265_GIT_FILES ${CMAKE_CURRENT_SOURCE_DIR}/patches/FFmpeg/x265_git/*.patch) diff --git a/cmake/git_fetch_tags.cmake b/cmake/git_fetch_tags.cmake new file mode 100644 index 00000000..c4d3a94d --- /dev/null +++ b/cmake/git_fetch_tags.cmake @@ -0,0 +1,10 @@ +# This macro fetches tags for the given git repository +# Arguments are path to git repository + +# GIT_FETCH_TAGS: args = `repo_path` +macro(GIT_FETCH_TAGS repo_path) + execute_process( + COMMAND git -C "${CMAKE_CURRENT_SOURCE_DIR}/${repo_path}" fetch --tags --depth=1 + COMMAND_ERROR_IS_FATAL ANY + ) +endmacro()