Skip to content

Commit 0de73c1

Browse files
Merge pull request #75 from maidamai0/master
👌 IMPROVE: add cmake script
2 parents 521757f + afde29f commit 0de73c1

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ bunny_1080p_60fps.mp4
44
bunny_1s_gop.mp4
55
bunny_1s_gop.mp4.ts
66
bunny_1s_gop.mp4.webm
7+
.vscode
8+
.clangd
9+
compile_commands.json

CMakeLists.txt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
cmake_minimum_required(VERSION 3.17)
2+
project(libav_tutorial)
3+
4+
# set out direcroty
5+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
6+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
7+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
8+
9+
# set ffmeg root directory
10+
if(NOT FFMPEG_DEV_ROOT)
11+
message(FATAL_ERROR "set FFMPEG_DEV_ROOT to use ffmpeg libraries")
12+
endif()
13+
14+
# set ffmpeg develop environment
15+
include_directories(${FFMPEG_DEV_ROOT}/include)
16+
link_directories(${FFMPEG_DEV_ROOT}/lib)
17+
link_libraries(
18+
avcodec
19+
avformat
20+
avfilter
21+
avdevice
22+
swresample
23+
swscale
24+
avutil
25+
)
26+
27+
# copy dlls
28+
file(GLOB ffmpeg_shared_libries ${FFMPEG_DEV_ROOT}/bin/*dll)
29+
file(COPY ${ffmpeg_shared_libries} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
30+
31+
# copy test file
32+
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/small_bunny_1080p_60fps.mp4 DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
33+
34+
35+
# add library
36+
set(debug_src ${CMAKE_CURRENT_SOURCE_DIR}/video_debugging.c)
37+
add_library(video_debug ${debug_src})
38+
link_libraries(video_debug)
39+
40+
# add project/executables
41+
file(GLOB srcs *.c)
42+
list(REMOVE_ITEM srcs ${debug_src})
43+
foreach(src ${srcs})
44+
get_filename_component(TARGET ${src} NAME)
45+
add_executable(${TARGET} ${src})
46+
message(STATUS "${TARGET} added")
47+
endforeach()
48+
49+

0 commit comments

Comments
 (0)