From 4e664e6681457d653c88e072c0ef30bcceac77e6 Mon Sep 17 00:00:00 2001 From: halx99 Date: Sat, 17 Jun 2023 00:26:46 +0800 Subject: [PATCH] Auto download vlc prebuilts if not found system - For windows, can easy enable vlc media via `-DAX_ENABLE_VLC_MEDIA=ON` --- cmake/Modules/AXBuildHelpers.cmake | 8 ++++++++ thirdparty/vlc/CMakeLists.txt | 13 +++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/AXBuildHelpers.cmake b/cmake/Modules/AXBuildHelpers.cmake index a398652e90f4..a1e8c29152c7 100644 --- a/cmake/Modules/AXBuildHelpers.cmake +++ b/cmake/Modules/AXBuildHelpers.cmake @@ -207,6 +207,14 @@ function(ax_copy_target_dll ax_target) $) endif() endif() + + # copy libvlc plugins dir for windows + if(AX_ENABLE_VLC_MEDIA) + add_custom_command(TARGET ${ax_target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory ${_AX_ROOT_PATH}/${_AX_THIRDPARTY_NAME}/vlc/win/lib/vlc/plugins + $/plugins + ) + endif() endfunction() function(ax_copy_lua_dlls ax_target) diff --git a/thirdparty/vlc/CMakeLists.txt b/thirdparty/vlc/CMakeLists.txt index 2a89ee906ac0..c4b9f3b0b4a8 100644 --- a/thirdparty/vlc/CMakeLists.txt +++ b/thirdparty/vlc/CMakeLists.txt @@ -5,6 +5,15 @@ project(${lib_name}) include(AXPlatform) +if (NOT (IS_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/${platform_name}")) + if (NOT EXISTS libvlc-dev-${platform_name}.zip) + message(STATUS "Downloading libvlc-dev-${platform_name}.zip ...") + file(DOWNLOAD https://github.com/halx99/build-vlc/releases/download/v3.0.18/libvlc-dev-${platform_name}.zip ${CMAKE_CURRENT_LIST_DIR}/libvlc-dev-${platform_name}.zip) + endif() + file(ARCHIVE_EXTRACT INPUT ${CMAKE_CURRENT_LIST_DIR}/libvlc-dev-${platform_name}.zip DESTINATION ${CMAKE_CURRENT_LIST_DIR}/) + file(RENAME ${CMAKE_CURRENT_LIST_DIR}/libvlc-dev-${platform_name} ${CMAKE_CURRENT_LIST_DIR}/${platform_name}) +endif() + # -----macro: set vlc sub target----- macro(set_vlc_sub_target sub_target_name sub_lib_name) add_library(${sub_target_name} SHARED IMPORTED GLOBAL) @@ -20,8 +29,8 @@ macro(set_vlc_sub_target sub_target_name sub_lib_name) ) elseif(WINDOWS) set_target_properties(${sub_target_name} PROPERTIES - IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/${platform_name}/lib/lib${sub_lib_name}.dll" - IMPORTED_IMPLIB "${CMAKE_CURRENT_LIST_DIR}/${platform_name}/lib/lib${sub_lib_name}.lib" + IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/${platform_name}/bin/lib${sub_lib_name}.dll" + IMPORTED_IMPLIB "${CMAKE_CURRENT_LIST_DIR}/${platform_name}/lib/lib${sub_lib_name}.dll.a" ) endif() endmacro()