Made the FFmpeg CMake find module work properly on NetBSD.

This commit is contained in:
Leon Styhre 2021-05-14 10:14:14 +02:00
parent 5e0b709c14
commit 63369ce48d

View file

@ -7,9 +7,9 @@
# $FFMPEG_DIR is an environment variable that would # $FFMPEG_DIR is an environment variable that would
# correspond to the ./configure --prefix=$FFMPEG_DIR # correspond to the ./configure --prefix=$FFMPEG_DIR
# #
# Created by Robert Osfield. # Created by Robert Osfield
# Modified by Lukas Lalinsky. # Modified by Lukas Lalinsky
# Modified by Leon Styhre. # Modified by Leon Styhre
# In ffmpeg code, old version use "#include <header.h>" and newer use "#include <libname/header.h>" # In ffmpeg code, old version use "#include <header.h>" and newer use "#include <libname/header.h>"
# In OSG ffmpeg plugin, we use "#include <header.h>" for compatibility with old version of ffmpeg # In OSG ffmpeg plugin, we use "#include <header.h>" for compatibility with old version of ffmpeg
@ -25,58 +25,43 @@
# Macro to find header and lib directories # Macro to find header and lib directories
# example: FFMPEG_FIND(AVFORMAT avformat avformat.h) # example: FFMPEG_FIND(AVFORMAT avformat avformat.h)
MACRO(FFMPEG_FIND varname shortname headername) macro(FFMPEG_FIND varname shortname headername)
FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS lib${shortname}/${headername} find_path(FFMPEG_${varname}_INCLUDE_DIRS lib${shortname}/${headername}
PATHS PATHS
${FFMPEG_ROOT}/include ${FFMPEG_ROOT}/include
$ENV{FFMPEG_DIR}/include $ENV{FFMPEG_DIR}/include
~/Library/Frameworks ~/Library/Frameworks
/Library/Frameworks /Library/Frameworks
/usr/local/include /usr/local/include
/usr/include/ /usr/pkg/include # NetBSD
/usr/include
/sw/include # Fink /sw/include # Fink
/opt/local/include # DarwinPorts /opt/local/include # DarwinPorts
/opt/csw/include # Blastwave /opt/csw/include # Blastwave
/opt/include /opt/include
/usr/freeware/include /usr/freeware/include
NO_DEFAULT_PATH NO_DEFAULT_PATH
PATH_SUFFIXES ffmpeg PATH_SUFFIXES
DOC "Location of FFMPEG Headers" ffmpeg
) ffmpeg4 # NetBSD
FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS lib${shortname}/${headername}
PATH_SUFFIXES ffmpeg
DOC "Location of FFMPEG Headers" DOC "Location of FFMPEG Headers"
) )
if(${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/pkg/lib/ffmpeg4/pkgconfig")
endif()
pkg_check_modules(FFMPEG_${varname} lib${shortname} REQUIRED) pkg_check_modules(FFMPEG_${varname} lib${shortname} REQUIRED)
IF (FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS) if(FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
SET(FFMPEG_${varname}_FOUND 1) set(FFMPEG_${varname}_FOUND 1)
MESSAGE("-- " ${FFMPEG_${varname}_LINK_LIBRARIES}) message("-- " ${FFMPEG_${varname}_LINK_LIBRARIES})
ENDIF(FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS) endif(FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
ENDMACRO(FFMPEG_FIND) endmacro(FFMPEG_FIND)
SET(FFMPEG_ROOT "$ENV{FFMPEG_DIR}" CACHE PATH "Location of FFMPEG") set(FFMPEG_ROOT "$ENV{FFMPEG_DIR}" CACHE PATH "Location of FFMPEG")
# find stdint.h
FIND_PATH(FFMPEG_STDINT_INCLUDE_DIR stdint.h
PATHS
${FFMPEG_ROOT}/include
$ENV{FFMPEG_DIR}/include
~/Library/Frameworks
/Library/Frameworks
/usr/local/include
/usr/include
/sw/include # Fink
/opt/local/include # DarwinPorts
/opt/csw/include # Blastwave
/opt/include
/usr/freeware/include
PATH_SUFFIXES ffmpeg
DOC "Location of FFMPEG stdint.h Header"
)
FFMPEG_FIND(LIBAVFORMAT avformat avformat.h) FFMPEG_FIND(LIBAVFORMAT avformat avformat.h)
FFMPEG_FIND(LIBAVCODEC avcodec avcodec.h) FFMPEG_FIND(LIBAVCODEC avcodec avcodec.h)
@ -85,23 +70,19 @@ FFMPEG_FIND(LIBAVUTIL avutil avutil.h)
FFMPEG_FIND(LIBSWRESAMPLE swresample swresample.h) FFMPEG_FIND(LIBSWRESAMPLE swresample swresample.h)
FFMPEG_FIND(LIBSWSCALE swscale swscale.h) # Not sure about the header to look for here. FFMPEG_FIND(LIBSWSCALE swscale swscale.h) # Not sure about the header to look for here.
SET(FFMPEG_FOUND "NO") set(FFMPEG_FOUND "NO")
IF (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND AND if(FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND AND
FFMPEG_LIBSWRESAMPLE_FOUND AND FFMPEG_LIBSWSCALE_FOUND AND FFMPEG_STDINT_INCLUDE_DIR) FFMPEG_LIBSWRESAMPLE_FOUND AND FFMPEG_LIBSWSCALE_FOUND)
SET(FFMPEG_FOUND "YES") set(FFMPEG_FOUND "YES")
SET(FFMPEG_INCLUDE_DIRS ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}) set(FFMPEG_INCLUDE_DIRS ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS})
SET(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBAVFORMAT_LIBRARY_DIRS}) set(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBAVFORMAT_LIBRARY_DIRS})
SET(FFMPEG_LIBRARIES set(FFMPEG_LIBRARIES
${FFMPEG_LIBAVFORMAT_LINK_LIBRARIES} ${FFMPEG_LIBAVFORMAT_LINK_LIBRARIES}
${FFMPEG_LIBAVCODEC_LINK_LIBRARIES} ${FFMPEG_LIBAVCODEC_LINK_LIBRARIES}
${FFMPEG_LIBAVUTIL_LINK_LIBRARIES} ${FFMPEG_LIBAVUTIL_LINK_LIBRARIES}
${FFMPEG_LIBSWRESAMPLE_LINK_LIBRARIES} ${FFMPEG_LIBSWRESAMPLE_LINK_LIBRARIES}
${FFMPEG_LIBSWSCALE_LINK_LIBRARIES}) ${FFMPEG_LIBSWSCALE_LINK_LIBRARIES})
ELSE () endif()
# MESSAGE(STATUS "Could not find FFMPEG")
ENDIF()