CMake: Fix vmaf with non-standard locations
The aom_dsp/vmaf.c change is due to vmaf using include/libvmaf as the
reported include dir. This change was also made in FFmpeg's libvmaf file
Tested with vmaf installed to $PWD/vmafinstall with
```bash
PKG_CONFIG_LIBDIR=$PWD/vmafinstall/lib/x86_64-linux-gnu/pkgconfig/ cmake -B bui -DCMAKE_BUILD_TYPE=Release -DCONFIG_TUNE_VMAF=1 -DBUILD_SHARED_LIBS=OFF
make -j -C bui
```
and with find_package(PkgConfig) commented out
```bash
cmake -B bui -DCMAKE_BUILD_TYPE=Release -DCONFIG_TUNE_VMAF=1 -DBUILD_SHARED_LIBS=OFF -DCMAKE_PREFIX_PATH=$PWD/vmafinstall
make -j -C bui
```
and both passed
BUG=aomedia:2748
Change-Id: I7bbc45e6d3b257966df03e54ba12f4f5100175bc
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6969189..6f7bf29 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -437,18 +437,24 @@
if(PKG_CONFIG_FOUND)
pkg_check_modules(VMAF REQUIRED libvmaf)
else()
- find_library(VMAF VMAF_LIBRARIES)
- if(NOT VMAF_LIBRARIES)
+ find_library(VMAF_LIBRARIES vmaf)
+ find_path(VMAF_INCLUDE_DIRS libvmaf.h PATH_SUFFIXES libvmaf)
+ if(VMAF_LIBRARIES AND VMAF_INCLUDE_DIRS)
+ message(STATUS "Found VMAF library: ${VMAF_LIBRARIES}")
+ message(STATUS "Found VMAF include: ${VMAF_INCLUDE_DIRS}")
+ else()
message(FATAL_ERROR "VMAF library not found.")
endif()
- message("-- Found VMAF library: " ${VMAF_LIBRARIES})
endif()
set_target_properties(aom PROPERTIES LINKER_LANGUAGE CXX)
if(BUILD_SHARED_LIBS)
set_target_properties(aom_static PROPERTIES LINKER_LANGUAGE CXX)
endif()
- target_link_libraries(aom PRIVATE ${VMAF_LIBRARIES})
- append_compiler_flag("${VMAF_CFLAGS}")
+ target_link_libraries(aom PRIVATE ${VMAF_LDFLAGS} ${VMAF_LIBRARIES})
+ target_include_directories(aom PRIVATE ${VMAF_INCLUDE_DIRS})
+ if(VMAF_CFLAGS)
+ append_compiler_flag("${VMAF_CFLAGS}")
+ endif()
endif()
endif()
diff --git a/aom_dsp/aom_dsp.cmake b/aom_dsp/aom_dsp.cmake
index 98527f4..b18a30f 100644
--- a/aom_dsp/aom_dsp.cmake
+++ b/aom_dsp/aom_dsp.cmake
@@ -334,6 +334,9 @@
if(BUILD_SHARED_LIBS)
target_sources(aom_static PRIVATE $<TARGET_OBJECTS:aom_dsp_encoder>)
endif()
+ if(CONFIG_TUNE_VMAF)
+ target_include_directories(aom_dsp_encoder PRIVATE ${VMAF_INCLUDE_DIRS})
+ endif()
endif()
if(HAVE_SSE2)
diff --git a/aom_dsp/vmaf.c b/aom_dsp/vmaf.c
index 12797a6..43b1452 100644
--- a/aom_dsp/vmaf.c
+++ b/aom_dsp/vmaf.c
@@ -10,7 +10,7 @@
*/
#include <assert.h>
-#include <libvmaf/libvmaf.h>
+#include <libvmaf.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>