-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
63 lines (50 loc) · 1.98 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#--------------------------------------------
# C++ language project template
#
# default folder structure as follows
# <project root folder>
# cmake/ <- here the additional modules with handy macro and finders
# include/
# src/
# test/
#
#--------------------------------------------
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
# use standard file endings - rename to cxx if needed
set(SRC_EXT_PATTERN ".cpp")
# rename to your name here
set(PROJECT_NAME vcffmpeg)
# define project for C++ language
project(${PROJECT_NAME} CXX)
# set where to find additional cmake modules if any
# comment it out if not required
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
# set compiler support for C++11 standard
option(USE_CXX11_STD "Product should be build with C++11 compiler option enabled" ON)
if(USE_CXX11_STD)
set(CMAKE_CXX_STANDARD 11)
endif()
# add include path for project
# add additional path if required
include_directories(${PROJECT_SOURCE_DIR}/include)
find_package(FFmpeg COMPONENTS AVCODEC AVFORMAT AVUTIL AVDEVICE REQUIRED)
if(FFMPEG_FOUND)
# FFMPEG_INCLUDE_DIRS - Include directory necessary for using the required components headers.
# FFMPEG_LIBRARIES - Link these to use the required ffmpeg components.
# FFMPEG_DEFINITIONS - Compiler switches required for using the required ffmpeg components.
message("FFMPEG_INCLUDE_DIRS = ${FFMPEG_INCLUDE_DIRS} ")
message("FFMPEG_LIBRARIES = ${FFMPEG_LIBRARIES} ")
message("FFMPEG_DEFINITIONS = ${FFMPEG_DEFINITIONS} ")
include_directories(${FFMPEG_INCLUDE_DIRS})
else()
message(FATAL_ERROR "FFMPEG not found")
endif()
# get all *.cpp files from src to build target
file(GLOB SRC_FILES ${PROJECT_SOURCE_DIR}/src/*${SRC_EXT_PATTERN})
source_group("Source Files" FILES ${SRC_FILES})
# build target
add_executable(${PROJECT_NAME} ${SRC_FILES})
if(MSVC)
target_include_directories(${PROJECT_NAME} PRIVATE include/msvc)
endif()
target_link_libraries(${PROJECT_NAME} ${FFMPEG_LIBRARIES})