Skip to content

Commit

Permalink
fix: link against transitive libaom library dependencies
Browse files Browse the repository at this point in the history
fixes #2274
  • Loading branch information
fdintino authored Jul 25, 2024
1 parent 9f8d3cc commit f086d98
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ The changes are relative to the previous release, unless the baseline is specifi
* Fix CMake config shared library leaks
https://github.com/AOMediaCodec/libavif/issues/2264.
* Fix clang-cl compilation.
* Fix aom link flags so that transitive library link flags are included when
aom is a static library
https://github.com/AOMediaCodec/libavif/issues/2274.

## [1.1.0] - 2024-07-11

Expand Down
10 changes: 10 additions & 0 deletions cmake/Modules/Findaom.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ 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_LIBRARIES "${_AOM_STATIC_LIBRARIES}")
# remove "aom" so we only have library dependencies
list(REMOVE_ITEM _AOM_PC_LIBRARIES "aom")

# Add absolute paths to libraries
foreach(_lib ${_AOM_PC_LIBRARIES})
find_library(_aom_dep_lib_${_lib} ${_lib} HINTS ${_AOM_STATIC_LIBRARY_DIRS})
target_link_libraries(aom INTERFACE ${_aom_dep_lib_${_lib}})
endforeach()
else()
add_library(aom SHARED IMPORTED GLOBAL)
endif()
Expand Down
21 changes: 21 additions & 0 deletions cmake/Modules/LocalAom.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@ 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(WIN32)
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)

set(_AOM_PC_LIBRARIES "${_AOM_STATIC_LIBRARIES}")
# remove "aom" so we only have library dependencies
list(REMOVE_ITEM _AOM_PC_LIBRARIES "aom")

# Add absolute paths to libraries
foreach(_lib ${_AOM_PC_LIBRARIES})
find_library(_aom_dep_lib_${_lib} ${_lib} HINTS ${_AOM_STATIC_LIBRARY_DIRS})
target_link_libraries(aom INTERFACE ${_aom_dep_lib_${_lib}})
endforeach()
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 f086d98

Please sign in to comment.