Skip to content

Commit a87d513

Browse files
committed
Merge pull request #246 from cchampet/cmake_fixDependencySwAvResample_2
CMake: fix double dependencies of av/sw resample
2 parents fed7209 + 05853e8 commit a87d513

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

cmake/FindFFmpeg.cmake

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,15 @@ macro(manage_components)
9494
# If the component is found.
9595
if(${COMPONENT}_FOUND)
9696
message(STATUS "Component ${COMPONENT} present.")
97-
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${${COMPONENT}_LIBRARIES})
98-
set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} ${${COMPONENT}_DEFINITIONS})
99-
list(APPEND FFMPEG_INCLUDE_DIR ${${COMPONENT}_INCLUDE_DIR})
97+
# Skip components which are in a different location
98+
# This prevents us to depend on libav system libraries if we build with ffmpeg (and the reverse).
99+
if(NOT FFMPEG_INCLUDE_DIR OR FFMPEG_INCLUDE_DIR STREQUAL ${${COMPONENT}_INCLUDE_DIR})
100+
set(FFMPEG_INCLUDE_DIR ${${COMPONENT}_INCLUDE_DIR})
101+
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${${COMPONENT}_LIBRARIES})
102+
set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} ${${COMPONENT}_DEFINITIONS})
103+
else()
104+
set(${COMPONENT}_FOUND FALSE)
105+
endif()
100106
else()
101107
if(FFmpeg_FIND_REQUIRED)
102108
message(SEND_ERROR "Error: required component ${COMPONENT} missing.")

src/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ include(AvTranscoderMacros)
66
find_package(FFmpeg COMPONENTS avcodec avformat avutil swscale swresample avresample)
77

88
# Check if FFmpeg or libav dependency
9-
if(avresample_FOUND)
10-
add_definitions(-DAVTRANSCODER_LIBAV_DEPENDENCY)
11-
message("Build avTranscoder with dependency to libav.")
12-
elseif(swresample_FOUND)
9+
if(swresample_FOUND)
1310
add_definitions(-DAVTRANSCODER_FFMPEG_DEPENDENCY)
1411
message("Build avTranscoder with dependency to ffmpeg.")
12+
elseif(avresample_FOUND)
13+
add_definitions(-DAVTRANSCODER_LIBAV_DEPENDENCY)
14+
message("Build avTranscoder with dependency to libav.")
1515
else()
1616
message(SEND_ERROR "Can't define if you depend on ffmpeg or libav.")
1717
endif()

0 commit comments

Comments
 (0)