Improve FFmpeg detection on debian systems; fix build when git is installed but there is no .git folder.

This commit is contained in:
sergiobenrocha2 2015-09-16 19:07:25 -03:00
parent 18f452ff29
commit e81fa01bf0
3 changed files with 150 additions and 119 deletions

View file

@ -430,7 +430,7 @@ include_directories(ext/native/ext/stb_vorbis)
if(USE_FFMPEG) if(USE_FFMPEG)
if(USE_SYSTEM_FFMPEG) if(USE_SYSTEM_FFMPEG)
include(FindFFMPEG) find_package(FFMPEG)
else() else()
set(FFMPEG_FOUND OFF) set(FFMPEG_FOUND OFF)
endif() endif()
@ -549,29 +549,29 @@ endif(USE_FFMPEG)
if(USE_FFMPEG AND DEFINED FFMPEG_LIBRARIES) if(USE_FFMPEG AND DEFINED FFMPEG_LIBRARIES)
message(STATUS "FFMPEG library locations:") message(STATUS "FFMPEG library locations:")
if(FFMPEG_FOUND) if(FFMPEG_FOUND)
message(STATUS "libavcodec location: ${FFMPEG_avcodec_LIBRARY}") message(STATUS " libavcodec location: ${FFMPEG_avcodec_LIBRARY}")
message(STATUS "libavformat location: ${FFMPEG_avformat_LIBRARY}") message(STATUS " libavformat location: ${FFMPEG_avformat_LIBRARY}")
message(STATUS "libavutil location: ${FFMPEG_avutil_LIBRARY}") message(STATUS " libavutil location: ${FFMPEG_avutil_LIBRARY}")
message(STATUS "libswresample location: ${FFMPEG_swresample_LIBRARY}") message(STATUS " libswresample location: ${FFMPEG_swresample_LIBRARY}")
message(STATUS "libswscale location: ${FFMPEG_swscale_LIBRARY}") message(STATUS " libswscale location: ${FFMPEG_swscale_LIBRARY}")
elseif(DEFINED PLATFORM_ARCH) elseif(DEFINED PLATFORM_ARCH)
set(TEMP ${CMAKE_SOURCE_DIR}/ffmpeg/${PLATFORM_ARCH}/lib) set(TEMP ${CMAKE_SOURCE_DIR}/ffmpeg/${PLATFORM_ARCH}/lib)
message(STATUS "libavcodec location: ${TEMP}/libavcodec.a") message(STATUS " libavcodec location: ${TEMP}/libavcodec.a")
message(STATUS "libavformat location: ${TEMP}/libavformat.a") message(STATUS " libavformat location: ${TEMP}/libavformat.a")
message(STATUS "libavutil location: ${TEMP}/libavutil.a") message(STATUS " libavutil location: ${TEMP}/libavutil.a")
message(STATUS "libswresample location: ${TEMP}/libswresample.a") message(STATUS " libswresample location: ${TEMP}/libswresample.a")
message(STATUS "libswscale location: ${TEMP}/libswscale.a") message(STATUS " libswscale location: ${TEMP}/libswscale.a")
else() else()
get_target_property(TEMP libavcodec IMPORTED_LOCATION) get_target_property(TEMP libavcodec IMPORTED_LOCATION)
message(STATUS "libavcodec location: ${TEMP}") message(STATUS " libavcodec location: ${TEMP}")
get_target_property(TEMP libavformat IMPORTED_LOCATION) get_target_property(TEMP libavformat IMPORTED_LOCATION)
message(STATUS "libavformat location: ${TEMP}") message(STATUS " libavformat location: ${TEMP}")
get_target_property(TEMP libavutil IMPORTED_LOCATION) get_target_property(TEMP libavutil IMPORTED_LOCATION)
message(STATUS "libavutil location: ${TEMP}") message(STATUS " libavutil location: ${TEMP}")
get_target_property(TEMP libswresample IMPORTED_LOCATION) get_target_property(TEMP libswresample IMPORTED_LOCATION)
message(STATUS "libswresample location: ${TEMP}") message(STATUS " libswresample location: ${TEMP}")
get_target_property(TEMP libswscale IMPORTED_LOCATION) get_target_property(TEMP libswscale IMPORTED_LOCATION)
message(STATUS "libswscale location: ${TEMP}") message(STATUS " libswscale location: ${TEMP}")
endif() endif()
else() else()
message(STATUS "ERROR: No FFMPEG library locations") message(STATUS "ERROR: No FFMPEG library locations")

View file

@ -30,70 +30,82 @@
# (To distribute this file outside of ppsspp, substitute the full # (To distribute this file outside of ppsspp, substitute the full
# License text for the above reference.) # License text for the above reference.)
find_path(FFMPEG_INCLUDE_DIR1 avformat.h if(EXISTS "/etc/debian_version")
$ENV{FFMPEG_DIR} set (PLATFORM "Debian")
$ENV{FFMPEG_DIR}/ffmpeg endif()
$ENV{FFMPEG_DIR}/libavformat
$ENV{FFMPEG_DIR}/include/libavformat
$ENV{FFMPEG_DIR}/include/ffmpeg
/usr/local/include/ffmpeg
/usr/include/ffmpeg
/usr/include/libavformat
/usr/include/ffmpeg/libavformat
/usr/local/include/libavformat
)
find_path(FFMPEG_INCLUDE_DIR2 avcodec.h if(${PLATFORM} MATCHES "Debian")
$ENV{FFMPEG_DIR} find_path(FFMPEG_INCLUDE_DIR1 libavformat/avformat.h)
$ENV{FFMPEG_DIR}/ffmpeg find_path(FFMPEG_INCLUDE_DIR2 libavcodec/avcodec.h)
$ENV{FFMPEG_DIR}/libavcodec find_path(FFMPEG_INCLUDE_DIR3 libavutil/avutil.h)
$ENV{FFMPEG_DIR}/include/libavcodec find_path(FFMPEG_INCLUDE_DIR4 libswresample/swresample.h)
$ENV{FFMPEG_DIR}/include/ffmpeg find_path(FFMPEG_INCLUDE_DIR5 libswscale/swscale.h)
/usr/local/include/ffmpeg else()
/usr/include/ffmpeg find_path(FFMPEG_INCLUDE_DIR1 avformat.h
/usr/include/libavcodec $ENV{FFMPEG_DIR}
/usr/include/ffmpeg/libavcodec $ENV{FFMPEG_DIR}/ffmpeg
/usr/local/include/libavcodec $ENV{FFMPEG_DIR}/libavformat
) $ENV{FFMPEG_DIR}/include/libavformat
$ENV{FFMPEG_DIR}/include/ffmpeg
/usr/local/include/ffmpeg
/usr/include/ffmpeg
/usr/include/libavformat
/usr/include/ffmpeg/libavformat
/usr/local/include/libavformat
)
find_path(FFMPEG_INCLUDE_DIR3 avutil.h find_path(FFMPEG_INCLUDE_DIR2 avcodec.h
$ENV{FFMPEG_DIR} $ENV{FFMPEG_DIR}
$ENV{FFMPEG_DIR}/ffmpeg $ENV{FFMPEG_DIR}/ffmpeg
$ENV{FFMPEG_DIR}/libavutil $ENV{FFMPEG_DIR}/libavcodec
$ENV{FFMPEG_DIR}/include/libavutil $ENV{FFMPEG_DIR}/include/libavcodec
$ENV{FFMPEG_DIR}/include/ffmpeg $ENV{FFMPEG_DIR}/include/ffmpeg
/usr/local/include/ffmpeg /usr/local/include/ffmpeg
/usr/include/ffmpeg /usr/include/ffmpeg
/usr/include/libavutil /usr/include/libavcodec
/usr/include/ffmpeg/libavutil /usr/include/ffmpeg/libavcodec
/usr/local/include/libavutil /usr/local/include/libavcodec
) )
find_path(FFMPEG_INCLUDE_DIR4 swresample.h find_path(FFMPEG_INCLUDE_DIR3 avutil.h
$ENV{FFMPEG_DIR} $ENV{FFMPEG_DIR}
$ENV{FFMPEG_DIR}/ffmpeg $ENV{FFMPEG_DIR}/ffmpeg
$ENV{FFMPEG_DIR}/libswresample $ENV{FFMPEG_DIR}/libavutil
$ENV{FFMPEG_DIR}/include/libswresample $ENV{FFMPEG_DIR}/include/libavutil
$ENV{FFMPEG_DIR}/include/ffmpeg $ENV{FFMPEG_DIR}/include/ffmpeg
/usr/local/include/ffmpeg /usr/local/include/ffmpeg
/usr/include/ffmpeg /usr/include/ffmpeg
/usr/include/libswresample /usr/include/libavutil
/usr/include/ffmpeg/libswresample /usr/include/ffmpeg/libavutil
/usr/local/include/libswresample /usr/local/include/libavutil
) )
find_path(FFMPEG_INCLUDE_DIR5 swscale.h find_path(FFMPEG_INCLUDE_DIR4 swresample.h
$ENV{FFMPEG_DIR} $ENV{FFMPEG_DIR}
$ENV{FFMPEG_DIR}/ffmpeg $ENV{FFMPEG_DIR}/ffmpeg
$ENV{FFMPEG_DIR}/libswscale $ENV{FFMPEG_DIR}/libswresample
$ENV{FFMPEG_DIR}/include/libswscale $ENV{FFMPEG_DIR}/include/libswresample
$ENV{FFMPEG_DIR}/include/ffmpeg $ENV{FFMPEG_DIR}/include/ffmpeg
/usr/local/include/ffmpeg /usr/local/include/ffmpeg
/usr/include/ffmpeg /usr/include/ffmpeg
/usr/include/libswscale /usr/include/libswresample
/usr/include/ffmpeg/libswscale /usr/include/ffmpeg/libswresample
/usr/local/include/libswscale /usr/local/include/libswresample
) )
find_path(FFMPEG_INCLUDE_DIR5 swscale.h
$ENV{FFMPEG_DIR}
$ENV{FFMPEG_DIR}/ffmpeg
$ENV{FFMPEG_DIR}/libswscale
$ENV{FFMPEG_DIR}/include/libswscale
$ENV{FFMPEG_DIR}/include/ffmpeg
/usr/local/include/ffmpeg
/usr/include/ffmpeg
/usr/include/libswscale
/usr/include/ffmpeg/libswscale
/usr/local/include/libswscale
)
endif()
if(FFMPEG_INCLUDE_DIR1 AND if(FFMPEG_INCLUDE_DIR1 AND
FFMPEG_INCLUDE_DIR2 AND FFMPEG_INCLUDE_DIR2 AND
@ -109,45 +121,53 @@ if(FFMPEG_INCLUDE_DIR1 AND
) )
endif() endif()
find_library(FFMPEG_avformat_LIBRARY avformat if(${PLATFORM} MATCHES "Debian")
$ENV{FFMPEG_DIR} find_library(FFMPEG_avformat_LIBRARY avformat-ffmpeg)
$ENV{FFMPEG_DIR}/lib find_library(FFMPEG_avcodec_LIBRARY avcodec-ffmpeg)
$ENV{FFMPEG_DIR}/libavformat find_library(FFMPEG_avutil_LIBRARY avutil-ffmpeg)
/usr/local/lib find_library(FFMPEG_swresample_LIBRARY swresample-ffmpeg)
/usr/lib find_library(FFMPEG_swscale_LIBRARY swscale-ffmpeg)
) else()
find_library(FFMPEG_avformat_LIBRARY avformat
$ENV{FFMPEG_DIR}
$ENV{FFMPEG_DIR}/lib
$ENV{FFMPEG_DIR}/libavformat
/usr/local/lib
/usr/lib
)
find_library(FFMPEG_avcodec_LIBRARY avcodec find_library(FFMPEG_avcodec_LIBRARY avcodec
$ENV{FFMPEG_DIR} $ENV{FFMPEG_DIR}
$ENV{FFMPEG_DIR}/lib $ENV{FFMPEG_DIR}/lib
$ENV{FFMPEG_DIR}/libavcodec $ENV{FFMPEG_DIR}/libavcodec
/usr/local/lib /usr/local/lib
/usr/lib /usr/lib
) )
find_library(FFMPEG_avutil_LIBRARY avutil find_library(FFMPEG_avutil_LIBRARY avutil
$ENV{FFMPEG_DIR} $ENV{FFMPEG_DIR}
$ENV{FFMPEG_DIR}/lib $ENV{FFMPEG_DIR}/lib
$ENV{FFMPEG_DIR}/libavutil $ENV{FFMPEG_DIR}/libavutil
/usr/local/lib /usr/local/lib
/usr/lib /usr/lib
) )
find_library(FFMPEG_swresample_LIBRARY swresample find_library(FFMPEG_swresample_LIBRARY swresample
$ENV{FFMPEG_DIR} $ENV{FFMPEG_DIR}
$ENV{FFMPEG_DIR}/lib $ENV{FFMPEG_DIR}/lib
$ENV{FFMPEG_DIR}/libswresample $ENV{FFMPEG_DIR}/libswresample
/usr/local/lib /usr/local/lib
/usr/lib /usr/lib
) )
find_library(FFMPEG_swscale_LIBRARY swscale find_library(FFMPEG_swscale_LIBRARY swscale
$ENV{FFMPEG_DIR} $ENV{FFMPEG_DIR}
$ENV{FFMPEG_DIR}/lib $ENV{FFMPEG_DIR}/lib
$ENV{FFMPEG_DIR}/libswscale $ENV{FFMPEG_DIR}/libswscale
/usr/local/lib /usr/local/lib
/usr/lib /usr/lib
) )
endif()
if(FFMPEG_INCLUDE_DIR) if(FFMPEG_INCLUDE_DIR)
if(FFMPEG_avformat_LIBRARY AND if(FFMPEG_avformat_LIBRARY AND
@ -157,11 +177,22 @@ if(FFMPEG_INCLUDE_DIR)
FFMPEG_swscale_LIBRARY FFMPEG_swscale_LIBRARY
) )
set(FFMPEG_FOUND "YES") set(FFMPEG_FOUND "YES")
set(FFMPEG_LIBRARIES ${FFMPEG_avformat_LIBRARY} if(${PLATFORM} MATCHES "Debian")
${FFMPEG_avcodec_LIBRARY} set(FFMPEG_LIBRARIES avformat-ffmpeg
${FFMPEG_avutil_LIBRARY} avcodec-ffmpeg
${FFMPEG_swresample_LIBRARY} avutil-ffmpeg
${FFMPEG_swscale_LIBRARY} swresample-ffmpeg
) swscale-ffmpeg
)
else()
set(FFMPEG_LIBRARIES ${FFMPEG_avformat_LIBRARY}
${FFMPEG_avcodec_LIBRARY}
${FFMPEG_avutil_LIBRARY}
${FFMPEG_swresample_LIBRARY}
${FFMPEG_swscale_LIBRARY}
)
endif()
endif() endif()
endif() endif()
unset (PLATFORM)

View file

@ -3,7 +3,7 @@ set(GIT_VERSION "unknown")
set(GIT_VERSION_UPDATE "1") set(GIT_VERSION_UPDATE "1")
find_package(Git) find_package(Git)
if(GIT_FOUND) if(GIT_FOUND AND EXISTS ".git")
execute_process(COMMAND ${GIT_EXECUTABLE} describe --always execute_process(COMMAND ${GIT_EXECUTABLE} describe --always
WORKING_DIRECTORY ${SOURCE_DIR} WORKING_DIRECTORY ${SOURCE_DIR}
RESULT_VARIABLE exit_code RESULT_VARIABLE exit_code
@ -39,4 +39,4 @@ set(code_string "// This is a generated file.\n\n"
if ("${GIT_VERSION_UPDATE}" EQUAL "1") if ("${GIT_VERSION_UPDATE}" EQUAL "1")
file(WRITE ${GIT_VERSION_FILE} ${code_string}) file(WRITE ${GIT_VERSION_FILE} ${code_string})
endif() endif()