-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
87 lines (68 loc) · 4.12 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
cmake_minimum_required (VERSION 3.9)
set(FFMPEG_NUGET_NAME "ffmpeg-lgpl")
set(FFMPEG_NUGET_VERSION "7.1.0")
# Enable Hot Reload for MSVC compilers if supported.
if(POLICY CMP0141)
cmake_policy(SET CMP0141 NEW)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()
if(NOT WIN32)
set(CMAKE_C_COMPILER gcc CACHE STRING "C compiler" FORCE)
set(CMAKE_CXX_COMPILER g++ CACHE STRING "C++ compiler" FORCE)
set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 23)
endif(NOT WIN32)
# Set up project information
file(READ "VERSION" PROJECT_FILE_VERSION)
project(Griffeye.VideoProcessor.Native VERSION ${PROJECT_FILE_VERSION} DESCRIPTION "Video frame extraction library using ffmpeg")
add_library(${PROJECT_NAME} SHARED
src/libvx.c
src/filter.c
src/filtergraph.c
src/util.c
)
# Set version, not required but good practice. Also symlink the major version to the full version.
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION})
set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR})
# Find and link to ffmpeg
if(WIN32)
set_target_properties(${PROJECT_NAME} PROPERTIES VS_USER_PROPS "${CMAKE_CURRENT_SOURCE_DIR}/Griffeye.VideoProcessor.Native.deps.props")
# Mandatory Nuget dependencies
set_property(TARGET ${PROJECT_NAME}
PROPERTY CMAKE_VS_NUGET_PACKAGE_RESTORE "ON"
)
set_property(TARGET ${PROJECT_NAME}
PROPERTY VS_PACKAGE_REFERENCES "${FFMPEG_NUGET_NAME}_${FFMPEG_NUGET_VERSION}"
)
else()
string(TOLOWER ${CMAKE_BUILD_TYPE} build_type)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
target_include_directories(${PROJECT_NAME} PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/Packages/${FFMPEG_NUGET_NAME}/${FFMPEG_NUGET_VERSION}/build/native/Unix/include/x64"
)
# Assumes FFMpeg NuGet package have been explicitly/externally restored to ${CMAKE_CURRENT_SOURCE_DIR}/Packages
set(FFMPEG_LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Packages/${FFMPEG_NUGET_NAME}/${FFMPEG_NUGET_VERSION}/build/native/Unix/lib/${build_type}/x64")
include(CMakePrintHelpers)
cmake_print_variables(FFMPEG_LIB_PATH)
find_library(AVUTIL_LIBRARY NAMES avutil PATHS ${FFMPEG_LIB_PATH} REQUIRED NO_DEFAULT_PATH NO_CACHE)
find_library(AVCODEC_LIBRARY NAMES avcodec PATHS ${FFMPEG_LIB_PATH} REQUIRED NO_DEFAULT_PATH NO_CACHE)
find_library(AVFORMAT_LIBRARY NAMES avformat PATHS ${FFMPEG_LIB_PATH} REQUIRED NO_DEFAULT_PATH NO_CACHE)
find_library(AVDEVICE_LIBRARY NAMES avdevice PATHS ${FFMPEG_LIB_PATH} REQUIRED NO_DEFAULT_PATH NO_CACHE)
find_library(SWSCALE_LIBRARY NAMES swscale PATHS ${FFMPEG_LIB_PATH} REQUIRED NO_DEFAULT_PATH NO_CACHE)
find_library(AVFILTER_LIBRARY NAMES avfilter PATHS ${FFMPEG_LIB_PATH} REQUIRED NO_DEFAULT_PATH NO_CACHE)
find_library(SWRESAMPLE_LIBRARY NAMES swresample PATHS ${FFMPEG_LIB_PATH} REQUIRED NO_DEFAULT_PATH NO_CACHE)
find_library(VPX_LIBRARY NAMES vpx PATHS ${FFMPEG_LIB_PATH} REQUIRED NO_DEFAULT_PATH NO_CACHE)
find_library(PKGCONF_LIBRARY NAMES pkgconf PATHS ${FFMPEG_LIB_PATH} REQUIRED NO_DEFAULT_PATH NO_CACHE)
find_library(DAV1D_LIBRARY NAMES dav1d PATHS ${FFMPEG_LIB_PATH} REQUIRED NO_DEFAULT_PATH NO_CACHE)
find_library(Z_LIBRARY NAMES z PATHS ${FFMPEG_LIB_PATH} REQUIRED NO_DEFAULT_PATH NO_CACHE)
set(FFMPEG_LIBS ${AVDEVICE_LIBRARY} ${AVFILTER_LIBRARY} ${AVFORMAT_LIBRARY} ${AVCODEC_LIBRARY} ${SWRESAMPLE_LIBRARY} ${SWSCALE_LIBRARY} ${AVUTIL_LIBRARY} ${VPX_LIBRARY} ${PKGCONF_LIBRARY} ${DAV1D_LIBRARY} ${Z_LIBRARY})
cmake_print_variables(FFMPEG_LIBS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdebug-prefix-map=/build/build_linux_debug=/usr/src/griffeye.videoprocessor")
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic")
target_link_libraries(${PROJECT_NAME} PUBLIC ${FFMPEG_LIBS})
endif()
# Public API
set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER include/libvx.h)
# Include sub-projects.
add_subdirectory("src")
# Install library
install(TARGETS ${PROJECT_NAME} DESTINATION lib/${PROJECT_NAME})