FindFFmpeg works on Windows
The application links with ffmpeg dll and needs a copy of it to works in the output binary location.
This commit is contained in:
+17
-1
@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.21)
|
||||
project(ffmini VERSION 0.0.1)
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON) # Group CMake targets inside a folder
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Generate compile_commands.json for language servers
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
@@ -24,6 +25,8 @@ FetchContent_Declare(
|
||||
list(APPEND FETCH_CONTENTS miniaudio)
|
||||
FetchContent_MakeAvailable(${FETCH_CONTENTS})
|
||||
|
||||
find_package(FFmpeg REQUIRED)
|
||||
|
||||
# Group dependencies in Visual Studio and Xcode
|
||||
if (CMAKE_GENERATOR MATCHES "Visual Studio" OR CMAKE_GENERATOR MATCHES "Xcode")
|
||||
set_target_properties(fmt PROPERTIES FOLDER deps)
|
||||
@@ -94,7 +97,7 @@ add_executable(ffmini ${HEADER_FILES} ${SOURCE_FILES})
|
||||
target_include_directories(ffmini
|
||||
PRIVATE
|
||||
${PROJECT_SOURCE_DIR}
|
||||
${PROJECT_SOURCE_DIR}/dsp
|
||||
${FFMPEG_INCLUDE_DIR}
|
||||
)
|
||||
target_compile_definitions(ffmini PRIVATE ${BASE_DEFINITIONS})
|
||||
target_compile_features(ffmini PRIVATE cxx_std_20)
|
||||
@@ -103,6 +106,19 @@ target_link_libraries(ffmini
|
||||
PRIVATE
|
||||
asio::asio
|
||||
fmt
|
||||
miniaudio::miniaudio
|
||||
${FFMPEG_AVCODEC_LIBRARY}
|
||||
${FFMPEG_AVDEVICE_LIBRARY}
|
||||
${FFMPEG_AVFILTER_LIBRARY}
|
||||
${FFMPEG_AVFORMAT_LIBRARY}
|
||||
${FFMPEG_AVUTIL_LIBRARY}
|
||||
)
|
||||
source_group(TREE "${CMAKE_CURRENT_LIST_DIR}" FILES ${SOURCE_FILES})
|
||||
|
||||
#add_custom_command(
|
||||
# TARGET ffmini # Change this to your actual target name
|
||||
# POST_BUILD
|
||||
# COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
# ${FFMPEG_AVCODEC_LIBRARY}
|
||||
# $<TARGET_FILE_DIR:ffmini> # Copy to the output directory of MyExecutable
|
||||
#)
|
||||
|
||||
Reference in New Issue
Block a user