Auto download vlc prebuilts if not found system

- For windows, can easy enable vlc media via `-DAX_ENABLE_VLC_MEDIA=ON`
This commit is contained in:
halx99 2023-06-17 00:26:46 +08:00
parent db761b79f2
commit 4e664e6681
2 changed files with 19 additions and 2 deletions

View File

@ -207,6 +207,14 @@ function(ax_copy_target_dll ax_target)
$<TARGET_FILE_DIR:${ax_target}>) $<TARGET_FILE_DIR:${ax_target}>)
endif() endif()
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
$<TARGET_FILE_DIR:${ax_target}>/plugins
)
endif()
endfunction() endfunction()
function(ax_copy_lua_dlls ax_target) function(ax_copy_lua_dlls ax_target)

View File

@ -5,6 +5,15 @@ project(${lib_name})
include(AXPlatform) 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-----
macro(set_vlc_sub_target sub_target_name sub_lib_name) macro(set_vlc_sub_target sub_target_name sub_lib_name)
add_library(${sub_target_name} SHARED IMPORTED GLOBAL) 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) elseif(WINDOWS)
set_target_properties(${sub_target_name} PROPERTIES set_target_properties(${sub_target_name} PROPERTIES
IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/${platform_name}/lib/lib${sub_lib_name}.dll" 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}.lib" IMPORTED_IMPLIB "${CMAKE_CURRENT_LIST_DIR}/${platform_name}/lib/lib${sub_lib_name}.dll.a"
) )
endif() endif()
endmacro() endmacro()