Skip to content

Commit

Permalink
Auto download vlc prebuilts if not found system
Browse files Browse the repository at this point in the history
- For windows, can easy enable vlc media via `-DAX_ENABLE_VLC_MEDIA=ON`
  • Loading branch information
halx99 committed Jun 16, 2023
1 parent db761b7 commit 4e664e6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
8 changes: 8 additions & 0 deletions cmake/Modules/AXBuildHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@ function(ax_copy_target_dll ax_target)
$<TARGET_FILE_DIR:${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
$<TARGET_FILE_DIR:${ax_target}>/plugins
)
endif()
endfunction()

function(ax_copy_lua_dlls ax_target)
Expand Down
13 changes: 11 additions & 2 deletions thirdparty/vlc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down

0 comments on commit 4e664e6

Please sign in to comment.