From 2fee173d7a12df64bb643e4d73420c8282dea13b Mon Sep 17 00:00:00 2001 From: wxf Date: Tue, 30 Jun 2020 21:45:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=85=88=E4=BD=BF=E7=94=A8=20pkg-conf?= =?UTF-8?q?ig=20=E6=9D=A5=E6=9F=A5=E6=89=BE=20AV*=20=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 部分主机上 ffmpeg 安装路径不标准, 默认查找方式不方便适应该方式 --- tests/CMakeLists.txt | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ee75592c..4458b8d1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -8,20 +8,38 @@ if (SDL2_FOUND) message(STATUS "found library:${SDL2_LIBRARY}") endif (SDL2_FOUND) +find_package(PkgConfig QUIET) + #查找ffmpeg/libutil是否安装 -find_package(AVUTIL QUIET) -if(AVUTIL_FOUND) - include_directories(${AVUTIL_INCLUDE_DIR}) - list(APPEND LINK_LIB_LIST ${AVUTIL_LIBRARIES}) - message(STATUS "found library:${AVUTIL_LIBRARIES}") +if(PKG_CONFIG_FOUND) + pkg_check_modules(AVUTIL QUIET IMPORTED_TARGET libavutil) + if(AVUTIL_FOUND) + list(APPEND LINK_LIB_LIST PkgConfig::AVUTIL) + message(STATUS "found library:${AVUTIL_LIBRARY}") + endif() +else() + find_package(AVUTIL QUIET) + if(AVUTIL_FOUND) + include_directories(${AVUTIL_INCLUDE_DIR}) + list(APPEND LINK_LIB_LIST ${AVUTIL_LIBRARIES}) + message(STATUS "found library:${AVUTIL_LIBRARIES}") + endif() endif() #查找ffmpeg/libavcodec是否安装 -find_package(AVCODEC QUIET) -if(AVCODEC_FOUND) - include_directories(${AVCODEC_INCLUDE_DIR}) - list(APPEND LINK_LIB_LIST ${AVCODEC_LIBRARIES}) - message(STATUS "found library:${AVCODEC_LIBRARIES}") +if(PKG_CONFIG_FOUND) + pkg_check_modules(AVCODEC QUIET IMPORTED_TARGET libavcodec) + if(AVCODEC_FOUND) + list(APPEND LINK_LIB_LIST PkgConfig::AVCODEC) + message(STATUS "found library:${AVCODEC_LIBRARY}") + endif() +else() + find_package(AVCODEC QUIET) + if(AVCODEC_FOUND) + include_directories(${AVCODEC_INCLUDE_DIR}) + list(APPEND LINK_LIB_LIST ${AVCODEC_LIBRARIES}) + message(STATUS "found library:${AVCODEC_LIBRARIES}") + endif() endif() aux_source_directory(. TEST_SRC_LIST)