Skip to content

Commit

Permalink
fix: link against transitive libaom library dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
fdintino committed Jul 22, 2024
1 parent 03acd65 commit 5d02d95
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmake/Modules/Findaom.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,18 @@ mark_as_advanced(AOM_INCLUDE_DIR AOM_LIBRARY AOM_LIBRARIES)
if(AOM_LIBRARY)
if("${AOM_LIBRARY}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")
add_library(aom STATIC IMPORTED GLOBAL)
set(_AOM_PC_PREFIX "_AOM_STATIC")
else()
add_library(aom SHARED IMPORTED GLOBAL)
set(_AOM_PC_PREFIX "_AOM")
endif()
set_target_properties(aom PROPERTIES IMPORTED_LOCATION "${AOM_LIBRARY}")
target_include_directories(aom INTERFACE ${AOM_INCLUDE_DIR})

target_link_directories(aom INTERFACE "${${_AOM_PC_PREFIX}_LIBRARY_DIRS}")

set(_AOM_PC_LIBRARIES "${${_AOM_PC_PREFIX}_LIBRARIES}")
# remove "aom" so we only have library dependencies
list(REMOVE_ITEM _AOM_PC_LIBRARIES "aom")
target_link_libraries(aom INTERFACE "${_AOM_PC_LIBRARIES}")
endif()
17 changes: 17 additions & 0 deletions cmake/Modules/LocalAom.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@ if(EXISTS "${LIB_FILENAME}")
# ext/avm/aom/aom_encoder.h includes config/aom_config.h which is generated by the local build of avm.
target_include_directories(aom INTERFACE "${AOM_EXT_SOURCE_DIR}/build.libavif")
endif()

# Add link dependency flags from the aom.pc file in ext/aom or ext/avm
# by prepending the build directory to PKG_CONFIG_PATH and then calling
# pkg_check_modules
if(MSVC)
set(ENV{PKG_CONFIG_PATH} "${AOM_EXT_SOURCE_DIR}/build.libavif;$ENV{PKG_CONFIG_PATH}")
else()
set(ENV{PKG_CONFIG_PATH} "${AOM_EXT_SOURCE_DIR}/build.libavif:$ENV{PKG_CONFIG_PATH}")
endif()

pkg_check_modules(_AOM QUIET aom)
target_link_directories(aom INTERFACE ${_AOM_STATIC_LIBRARY_DIRS})

set(_AOM_PC_LIBRARIES ${_AOM_STATIC_LIBRARIES})
# remove "aom" so we only have library dependencies
list(REMOVE_ITEM _AOM_PC_LIBRARIES "aom")
target_link_libraries(aom INTERFACE ${_AOM_PC_LIBRARIES})
else()
message(STATUS "${AOM_MESSAGE_PREFIX}: compiled library not found at ${LIB_FILENAME}, using FetchContent")
if(EXISTS "${AOM_EXT_SOURCE_DIR}")
Expand Down

0 comments on commit 5d02d95

Please sign in to comment.