Commit 84f2d796 authored by Tom Finegan's avatar Tom Finegan

Add shared library support to the CMake build.

This is enabled via:
$ cmake path/to/aom -DBUILD_SHARED_LIBS=1

Currently supports only Linux and MacOS targets. Symbol visibility
is handled by exports.cmake and its helpers exports_sources.cmake
and generate_exports.cmake.

Some sweeping changes were required to properly support shared libs
and control symbol visibility:

- Object libraries are always linked privately into static
  libraries.
- Static libraries are always linked privately into eachother
  in the many cases where the CMake build merges multiple library
  targets.
- aom_dsp.cmake now links all its targets into the aom_dsp static
  library target, and privately links aom_dsp into the aom target.
- av1.cmake now links all its targets into the aom_av1 static library
  target, and privately links in aom_dsp and aom_scale as well. It
  then privately links aom_av1 into the aom target.
- The aom_mem, aom_ports, aom_scale, and aom_util targets are now
  static libs that are privately linked into the aom target.
- In CMakeLists.txt libyuv and libwebm are now privately linked into
  app targets.
- The ASM and intrinsic library functions in aom_optimization.cmake
  now both require a dependent target argument. This facilitates the
  changes noted above regarding new privately linked static library
  targets for ASM and intrinsics sources.

BUG=aomedia:76,aomedia:556

Change-Id: I4892059880c5de0f479da2e9c21d8ba2fa7390c3
parent 81b2e502
...@@ -23,6 +23,9 @@ option(ENABLE_NASM "Use nasm instead of yasm for x86 assembly." OFF) ...@@ -23,6 +23,9 @@ option(ENABLE_NASM "Use nasm instead of yasm for x86 assembly." OFF)
option(ENABLE_IDE_TEST_HOSTING option(ENABLE_IDE_TEST_HOSTING
"Enables running tests within IDEs like Visual Studio and Xcode." OFF) "Enables running tests within IDEs like Visual Studio and Xcode." OFF)
# $BUILD_SHARED_LIBS is a CMake built-in-- it's listed here for visibility.
option(BUILD_SHARED_LIBS "CMake should generate a shared library build." OFF)
project(AOM C CXX) project(AOM C CXX)
set(AOM_ROOT "${CMAKE_CURRENT_SOURCE_DIR}") set(AOM_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
...@@ -36,7 +39,6 @@ if ("${AOM_ROOT}" STREQUAL "${AOM_CONFIG_DIR}") ...@@ -36,7 +39,6 @@ if ("${AOM_ROOT}" STREQUAL "${AOM_CONFIG_DIR}")
endif () endif ()
include("${AOM_ROOT}/build/cmake/aom_configure.cmake") include("${AOM_ROOT}/build/cmake/aom_configure.cmake")
include("${AOM_ROOT}/build/cmake/aom_optimization.cmake")
include("${AOM_ROOT}/aom_dsp/aom_dsp.cmake") include("${AOM_ROOT}/aom_dsp/aom_dsp.cmake")
include("${AOM_ROOT}/aom_mem/aom_mem.cmake") include("${AOM_ROOT}/aom_mem/aom_mem.cmake")
include("${AOM_ROOT}/aom_ports/aom_ports.cmake") include("${AOM_ROOT}/aom_ports/aom_ports.cmake")
...@@ -44,6 +46,7 @@ include("${AOM_ROOT}/aom_scale/aom_scale.cmake") ...@@ -44,6 +46,7 @@ include("${AOM_ROOT}/aom_scale/aom_scale.cmake")
include("${AOM_ROOT}/aom_util/aom_util.cmake") include("${AOM_ROOT}/aom_util/aom_util.cmake")
include("${AOM_ROOT}/av1/av1.cmake") include("${AOM_ROOT}/av1/av1.cmake")
include("${AOM_ROOT}/test/test.cmake") include("${AOM_ROOT}/test/test.cmake")
include("${AOM_ROOT}/build/cmake/util.cmake")
set(AOM_RTCD_SOURCES set(AOM_RTCD_SOURCES
"${AOM_CONFIG_DIR}/aom_dsp_rtcd.h" "${AOM_CONFIG_DIR}/aom_dsp_rtcd.h"
...@@ -214,9 +217,9 @@ add_library(aom_common_app_util OBJECT ${AOM_COMMON_APP_UTIL_SOURCES}) ...@@ -214,9 +217,9 @@ add_library(aom_common_app_util OBJECT ${AOM_COMMON_APP_UTIL_SOURCES})
if (CONFIG_AV1_DECODER) if (CONFIG_AV1_DECODER)
add_library(aom_decoder_app_util OBJECT ${AOM_DECODER_APP_UTIL_SOURCES}) add_library(aom_decoder_app_util OBJECT ${AOM_DECODER_APP_UTIL_SOURCES})
add_executable(aomdec add_executable(aomdec
"${AOM_ROOT}/aomdec.c" "${AOM_ROOT}/aomdec.c"
$<TARGET_OBJECTS:aom_common_app_util> $<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>) $<TARGET_OBJECTS:aom_decoder_app_util>)
if (CONFIG_ANALYZER) if (CONFIG_ANALYZER)
add_executable(analyzer add_executable(analyzer
...@@ -326,7 +329,7 @@ if (CONFIG_LIBYUV) ...@@ -326,7 +329,7 @@ if (CONFIG_LIBYUV)
# Add to existing targets. # Add to existing targets.
foreach (aom_app ${AOM_APP_TARGETS}) foreach (aom_app ${AOM_APP_TARGETS})
target_sources(${aom_app} PUBLIC $<TARGET_OBJECTS:yuv>) target_sources(${aom_app} PRIVATE $<TARGET_OBJECTS:yuv>)
set_property(TARGET ${aom_app} PROPERTY LINKER_LANGUAGE CXX) set_property(TARGET ${aom_app} PROPERTY LINKER_LANGUAGE CXX)
endforeach () endforeach ()
endif () endif ()
...@@ -341,15 +344,15 @@ if (CONFIG_WEBM_IO) ...@@ -341,15 +344,15 @@ if (CONFIG_WEBM_IO)
# Add to existing targets. # Add to existing targets.
if (CONFIG_AV1_DECODER) if (CONFIG_AV1_DECODER)
target_sources(aom_decoder_app_util PUBLIC ${AOM_WEBM_DECODER_SOURCES}) target_sources(aom_decoder_app_util PRIVATE ${AOM_WEBM_DECODER_SOURCES})
endif () endif ()
if (CONFIG_AV1_ENCODER) if (CONFIG_AV1_ENCODER)
target_sources(aom_encoder_app_util PUBLIC ${AOM_WEBM_ENCODER_SOURCES}) target_sources(aom_encoder_app_util PRIVATE ${AOM_WEBM_ENCODER_SOURCES})
endif () endif ()
foreach (aom_app ${AOM_APP_TARGETS}) foreach (aom_app ${AOM_APP_TARGETS})
target_sources(${aom_app} PUBLIC $<TARGET_OBJECTS:webm>) target_sources(${aom_app} PRIVATE $<TARGET_OBJECTS:webm>)
set_property(TARGET ${aom_app} PROPERTY LINKER_LANGUAGE CXX) set_property(TARGET ${aom_app} PROPERTY LINKER_LANGUAGE CXX)
endforeach () endforeach ()
endif () endif ()
...@@ -376,11 +379,8 @@ if (XCODE) ...@@ -376,11 +379,8 @@ if (XCODE)
# Note: LINKER_LANGUAGE is explicitly set to C++ for all targets touched # Note: LINKER_LANGUAGE is explicitly set to C++ for all targets touched
# here, it really is the Xcode generator's fault, or just a deficiency in # here, it really is the Xcode generator's fault, or just a deficiency in
# Xcode itself. # Xcode itself.
set(XCODE_DUMMY_CXX_FILE "${AOM_CONFIG_DIR}/dummy.cc")
file(WRITE "${XCODE_DUMMY_CXX_FILE}"
"// Xcode needs a C++ file to link, ignore this file.")
foreach (aom_app ${AOM_APP_TARGETS}) foreach (aom_app ${AOM_APP_TARGETS})
target_sources(${aom_app} PUBLIC "${XCODE_DUMMY_CXX_FILE}") add_dummy_source_file_to_target("${aom_app}" "cc")
endforeach () endforeach ()
endif () endif ()
endif () endif ()
...@@ -393,6 +393,11 @@ if ("${CMAKE_GENERATOR}" MATCHES "Makefiles$" ) ...@@ -393,6 +393,11 @@ if ("${CMAKE_GENERATOR}" MATCHES "Makefiles$" )
RUNTIME_OUTPUT_DIRECTORY "${AOM_CONFIG_DIR}/examples") RUNTIME_OUTPUT_DIRECTORY "${AOM_CONFIG_DIR}/examples")
endif () endif ()
if (BUILD_SHARED_LIBS)
include("${AOM_ROOT}/build/cmake/exports.cmake")
setup_exports_target()
endif ()
# Aomedia documentation rule. # Aomedia documentation rule.
if (ENABLE_DOCS) if (ENABLE_DOCS)
include(FindDoxygen) include(FindDoxygen)
......
...@@ -46,6 +46,16 @@ configuration options can be found at the top of the CMakeLists.txt file found ...@@ -46,6 +46,16 @@ configuration options can be found at the top of the CMakeLists.txt file found
in the root of the AV1 repository, and AV1 codec configuration options can in the root of the AV1 repository, and AV1 codec configuration options can
currently be found in the file `build/cmake/aom_config_defaults.cmake`. currently be found in the file `build/cmake/aom_config_defaults.cmake`.
### Dylib builds
A dylib (shared object) build of the AV1 codec library can be enabled via the
CMake built in variable BUILD\_SHARED\_LIBS:
$ cmake path/to/aom -D BUILD_SHARED_LIBS=1
$ make
This is currently only supported on non-Windows targets.
### Cross compiling ### Cross compiling
For the purposes of building the AV1 codec and applications and relative to the For the purposes of building the AV1 codec and applications and relative to the
......
...@@ -414,111 +414,123 @@ endif () ...@@ -414,111 +414,123 @@ endif ()
# has been created. # has been created.
function (setup_aom_dsp_targets) function (setup_aom_dsp_targets)
add_library(aom_dsp_common OBJECT ${AOM_DSP_COMMON_SOURCES}) add_library(aom_dsp_common OBJECT ${AOM_DSP_COMMON_SOURCES})
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_dsp_common) list(APPEND AOM_LIB_TARGETS aom_dsp_common)
target_sources(aom PUBLIC $<TARGET_OBJECTS:aom_dsp_common>) add_library(aom_dsp STATIC $<TARGET_OBJECTS:aom_dsp_common>)
list(APPEND AOM_LIB_TARGETS aom_dsp)
# Not all generators support libraries consisting only of object files. Add a
# dummy source file to the aom_dsp target.
add_dummy_source_file_to_target("aom_dsp" "c")
if (CONFIG_AV1_DECODER) if (CONFIG_AV1_DECODER)
add_library(aom_dsp_decoder OBJECT ${AOM_DSP_DECODER_SOURCES}) add_library(aom_dsp_decoder OBJECT ${AOM_DSP_DECODER_SOURCES})
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_dsp_decoder) set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_dsp_decoder)
target_sources(aom PUBLIC $<TARGET_OBJECTS:aom_dsp_decoder>) target_sources(aom_dsp PRIVATE $<TARGET_OBJECTS:aom_dsp_decoder>)
endif () endif ()
if (CONFIG_AV1_ENCODER) if (CONFIG_AV1_ENCODER)
add_library(aom_dsp_encoder OBJECT ${AOM_DSP_ENCODER_SOURCES}) add_library(aom_dsp_encoder OBJECT ${AOM_DSP_ENCODER_SOURCES})
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_dsp_encoder) set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_dsp_encoder)
target_sources(aom PUBLIC $<TARGET_OBJECTS:aom_dsp_encoder>) target_sources(aom_dsp PRIVATE $<TARGET_OBJECTS:aom_dsp_encoder>)
endif () endif ()
if (HAVE_SSE2) if (HAVE_SSE2)
add_asm_library("aom_dsp_common_sse2" "AOM_DSP_COMMON_ASM_SSE2" "aom") add_asm_library("aom_dsp_common_sse2" "AOM_DSP_COMMON_ASM_SSE2" "aom_dsp")
add_intrinsics_object_library("-msse2" "sse2" "aom_dsp_common" add_intrinsics_object_library("-msse2" "sse2" "aom_dsp_common"
"AOM_DSP_COMMON_INTRIN_SSE2") "AOM_DSP_COMMON_INTRIN_SSE2" "aom_dsp")
if (CONFIG_AV1_ENCODER) if (CONFIG_AV1_ENCODER)
add_asm_library("aom_dsp_encoder_sse2" "AOM_DSP_ENCODER_ASM_SSE2" "aom") add_asm_library("aom_dsp_encoder_sse2" "AOM_DSP_ENCODER_ASM_SSE2"
"aom_dsp")
add_intrinsics_object_library("-msse2" "sse2" "aom_dsp_encoder" add_intrinsics_object_library("-msse2" "sse2" "aom_dsp_encoder"
"AOM_DSP_ENCODER_INTRIN_SSE2") "AOM_DSP_ENCODER_INTRIN_SSE2" "aom_dsp")
endif() endif()
endif () endif ()
if (HAVE_SSE3 AND CONFIG_AV1_ENCODER) if (HAVE_SSE3 AND CONFIG_AV1_ENCODER)
add_asm_library("aom_dsp_encoder_sse3" "AOM_DSP_ENCODER_INTRIN_SSE3" "aom") add_asm_library("aom_dsp_encoder_sse3" "AOM_DSP_ENCODER_INTRIN_SSE3"
"aom_dsp")
endif () endif ()
if (HAVE_SSSE3) if (HAVE_SSSE3)
add_asm_library("aom_dsp_common_ssse3" "AOM_DSP_COMMON_ASM_SSSE3" "aom") add_asm_library("aom_dsp_common_ssse3" "AOM_DSP_COMMON_ASM_SSSE3" "aom_dsp")
add_intrinsics_object_library("-mssse3" "ssse3" "aom_dsp_common" add_intrinsics_object_library("-mssse3" "ssse3" "aom_dsp_common"
"AOM_DSP_COMMON_INTRIN_SSSE3") "AOM_DSP_COMMON_INTRIN_SSSE3" "aom_dsp")
if (CONFIG_AV1_ENCODER) if (CONFIG_AV1_ENCODER)
if ("${AOM_TARGET_CPU}" STREQUAL "x86_64") if ("${AOM_TARGET_CPU}" STREQUAL "x86_64")
list(APPEND AOM_DSP_ENCODER_ASM_SSSE3 list(APPEND AOM_DSP_ENCODER_ASM_SSSE3
${AOM_DSP_ENCODER_ASM_SSSE3_X86_64}) ${AOM_DSP_ENCODER_ASM_SSSE3_X86_64})
endif () endif ()
add_asm_library("aom_dsp_encoder_ssse3" "AOM_DSP_ENCODER_ASM_SSSE3" "aom") add_asm_library("aom_dsp_encoder_ssse3" "AOM_DSP_ENCODER_ASM_SSSE3"
"aom_dsp")
if (AOM_DSP_ENCODER_INTRIN_SSSE3) if (AOM_DSP_ENCODER_INTRIN_SSSE3)
add_intrinsics_object_library("-mssse3" "ssse3" "aom_dsp_encoder" add_intrinsics_object_library("-mssse3" "ssse3" "aom_dsp_encoder"
"AOM_DSP_ENCODER_INTRIN_SSSE3") "AOM_DSP_ENCODER_INTRIN_SSSE3" "aom_dsp")
endif () endif ()
endif () endif ()
endif () endif ()
if (HAVE_SSE4_1) if (HAVE_SSE4_1)
add_intrinsics_object_library("-msse4.1" "sse4_1" "aom_dsp_common" add_intrinsics_object_library("-msse4.1" "sse4_1" "aom_dsp_common"
"AOM_DSP_COMMON_INTRIN_SSE4_1") "AOM_DSP_COMMON_INTRIN_SSE4_1" "aom_dsp")
if (CONFIG_AV1_ENCODER) if (CONFIG_AV1_ENCODER)
if (AOM_DSP_ENCODER_INTRIN_SSE4_1) if (AOM_DSP_ENCODER_INTRIN_SSE4_1)
add_intrinsics_object_library("-msse4.1" "sse4_1" "aom_dsp_encoder" add_intrinsics_object_library("-msse4.1" "sse4_1" "aom_dsp_encoder"
"AOM_DSP_ENCODER_INTRIN_SSE4_1") "AOM_DSP_ENCODER_INTRIN_SSE4_1" "aom_dsp")
endif () endif ()
add_asm_library("aom_dsp_encoder_sse4_1" "AOM_DSP_ENCODER_ASM_SSE4_1" add_asm_library("aom_dsp_encoder_sse4_1" "AOM_DSP_ENCODER_ASM_SSE4_1"
"aom") "aom_dsp")
endif () endif ()
endif () endif ()
if (HAVE_AVX AND "${AOM_TARGET_CPU}" STREQUAL "x86_64") if (HAVE_AVX AND "${AOM_TARGET_CPU}" STREQUAL "x86_64")
if (CONFIG_AV1_ENCODER) if (CONFIG_AV1_ENCODER)
add_asm_library("aom_dsp_encoder_avx" "AOM_DSP_ENCODER_AVX_ASM_X86_64" add_asm_library("aom_dsp_encoder_avx" "AOM_DSP_ENCODER_AVX_ASM_X86_64"
"aom") "aom_dsp")
endif () endif ()
endif () endif ()
if (HAVE_AVX2) if (HAVE_AVX2)
add_intrinsics_object_library("-mavx2" "avx2" "aom_dsp_common" add_intrinsics_object_library("-mavx2" "avx2" "aom_dsp_common"
"AOM_DSP_COMMON_INTRIN_AVX2") "AOM_DSP_COMMON_INTRIN_AVX2" "aom_dsp")
if (CONFIG_AV1_ENCODER) if (CONFIG_AV1_ENCODER)
add_intrinsics_object_library("-mavx2" "avx2" "aom_dsp_encoder" add_intrinsics_object_library("-mavx2" "avx2" "aom_dsp_encoder"
"AOM_DSP_ENCODER_INTRIN_AVX2") "AOM_DSP_ENCODER_INTRIN_AVX2" "aom_dsp")
endif () endif ()
endif () endif ()
if (HAVE_NEON_ASM) if (HAVE_NEON_ASM)
if (AOM_ADS2GAS_REQUIRED) if (AOM_ADS2GAS_REQUIRED)
add_gas_asm_library("aom_dsp_common_neon" "AOM_DSP_COMMON_ASM_NEON" "aom") add_gas_asm_library("aom_dsp_common_neon" "AOM_DSP_COMMON_ASM_NEON"
"aom_dsp")
else () else ()
add_asm_library("aom_dsp_common_neon" "AOM_DSP_COMMON_ASM_NEON" "aom") add_asm_library("aom_dsp_common_neon" "AOM_DSP_COMMON_ASM_NEON" "aom_dsp")
endif () endif ()
endif () endif ()
if (HAVE_NEON) if (HAVE_NEON)
add_intrinsics_object_library("${AOM_NEON_INTRIN_FLAG}" "neon" add_intrinsics_object_library("${AOM_NEON_INTRIN_FLAG}" "neon"
"aom_dsp_common" "AOM_DSP_COMMON_INTRIN_NEON") "aom_dsp_common" "AOM_DSP_COMMON_INTRIN_NEON"
"aom_dsp")
endif () endif ()
if (HAVE_DSPR2) if (HAVE_DSPR2)
add_intrinsics_object_library("" "dspr2" "aom_dsp_common" add_intrinsics_object_library("" "dspr2" "aom_dsp_common"
"AOM_DSP_COMMON_INTRIN_DSPR2") "AOM_DSP_COMMON_INTRIN_DSPR2" "aom_dsp")
endif () endif ()
if (HAVE_MSA) if (HAVE_MSA)
add_intrinsics_object_library("" "msa" "aom_dsp_common" add_intrinsics_object_library("" "msa" "aom_dsp_common"
"AOM_DSP_COMMON_INTRIN_MSA") "AOM_DSP_COMMON_INTRIN_MSA" "aom_dsp")
if (CONFIG_AV1_ENCODER) if (CONFIG_AV1_ENCODER)
add_intrinsics_object_library("" "msa" "aom_dsp_encoder" add_intrinsics_object_library("" "msa" "aom_dsp_encoder"
"AOM_DSP_ENCODER_INTRIN_MSA") "AOM_DSP_ENCODER_INTRIN_MSA" "aom_dsp")
endif () endif ()
endif () endif ()
target_link_libraries(aom PRIVATE aom_dsp)
# Pass the new lib targets up to the parent scope instance of # Pass the new lib targets up to the parent scope instance of
# $AOM_LIB_TARGETS. # $AOM_LIB_TARGETS.
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} PARENT_SCOPE) set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} PARENT_SCOPE)
......
...@@ -19,9 +19,9 @@ set(AOM_MEM_SOURCES ...@@ -19,9 +19,9 @@ set(AOM_MEM_SOURCES
# Creates the aom_mem build target and makes libaom depend on it. The libaom # Creates the aom_mem build target and makes libaom depend on it. The libaom
# target must exist before this function is called. # target must exist before this function is called.
function (setup_aom_mem_targets) function (setup_aom_mem_targets)
add_library(aom_mem OBJECT ${AOM_MEM_SOURCES}) add_library(aom_mem STATIC ${AOM_MEM_SOURCES})
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_mem PARENT_SCOPE) set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_mem PARENT_SCOPE)
target_sources(aom PUBLIC $<TARGET_OBJECTS:aom_mem>) target_link_libraries(aom PRIVATE aom_mem)
endfunction () endfunction ()
endif () # AOM_AOM_MEM_AOM_MEM_CMAKE_ endif () # AOM_AOM_MEM_AOM_MEM_CMAKE_
...@@ -43,27 +43,26 @@ function (setup_aom_ports_targets) ...@@ -43,27 +43,26 @@ function (setup_aom_ports_targets)
add_asm_library("aom_ports" "AOM_PORTS_ASM_MMX" "aom") add_asm_library("aom_ports" "AOM_PORTS_ASM_MMX" "aom")
set(aom_ports_has_symbols 1) set(aom_ports_has_symbols 1)
elseif ("${AOM_TARGET_CPU}" MATCHES "arm") elseif ("${AOM_TARGET_CPU}" MATCHES "arm")
add_library(aom_ports OBJECT ${AOM_PORTS_SOURCES_ARM}) add_library(aom_ports STATIC ${AOM_PORTS_SOURCES_ARM})
set(aom_ports_has_symbols 1) set(aom_ports_has_symbols 1)
list(APPEND AOM_LIB_TARGETS aom_ports) target_link_libraries(aom PRIVATE aom_ports)
target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_ports>)
endif () endif ()
if (aom_ports_has_symbols) if (aom_ports_has_symbols)
target_sources(aom_ports PUBLIC ${AOM_PORTS_INCLUDES}) target_sources(aom_ports PRIVATE ${AOM_PORTS_INCLUDES})
if ("${AOM_TARGET_CPU}" STREQUAL "x86" OR if ("${AOM_TARGET_CPU}" STREQUAL "x86" OR
"${AOM_TARGET_CPU}" STREQUAL "x86_64") "${AOM_TARGET_CPU}" STREQUAL "x86_64")
target_sources(aom_ports PUBLIC ${AOM_PORTS_INCLUDES_X86}) target_sources(aom_ports PRIVATE ${AOM_PORTS_INCLUDES_X86})
endif () endif ()
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} PARENT_SCOPE) set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} PARENT_SCOPE)
else () else ()
target_sources(aom PUBLIC ${AOM_PORTS_INCLUDES}) target_sources(aom PRIVATE ${AOM_PORTS_INCLUDES})
if ("${AOM_TARGET_CPU}" STREQUAL "x86" OR if ("${AOM_TARGET_CPU}" STREQUAL "x86" OR
"${AOM_TARGET_CPU}" STREQUAL "x86_64") "${AOM_TARGET_CPU}" STREQUAL "x86_64")
target_sources(aom PUBLIC ${AOM_PORTS_INCLUDES_X86}) target_sources(aom PRIVATE ${AOM_PORTS_INCLUDES_X86})
endif () endif ()
endif () endif ()
endfunction () endfunction ()
......
...@@ -25,12 +25,12 @@ set(AOM_SCALE_INTRIN_DSPR2 ...@@ -25,12 +25,12 @@ set(AOM_SCALE_INTRIN_DSPR2
# Creates the aom_scale build target and makes libaom depend on it. The libaom # Creates the aom_scale build target and makes libaom depend on it. The libaom
# target must exist before this function is called. # target must exist before this function is called.
function (setup_aom_scale_targets) function (setup_aom_scale_targets)
add_library(aom_scale OBJECT ${AOM_SCALE_SOURCES}) add_library(aom_scale STATIC ${AOM_SCALE_SOURCES})
target_sources(aom PUBLIC $<TARGET_OBJECTS:aom_scale>) target_link_libraries(aom PRIVATE aom_scale)
if (HAVE_DSPR2) if (HAVE_DSPR2)
add_intrinsics_object_library("" "dspr2" "aom_scale" add_intrinsics_object_library("" "dspr2" "aom_scale"
"AOM_SCALE_INTRIN_DSPR2") "AOM_SCALE_INTRIN_DSPR2" "aom_scale")
endif () endif ()
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_scale PARENT_SCOPE) set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_scale PARENT_SCOPE)
......
...@@ -26,9 +26,9 @@ endif () ...@@ -26,9 +26,9 @@ endif ()
# Creates the aom_util build target and makes libaom depend on it. The libaom # Creates the aom_util build target and makes libaom depend on it. The libaom
# target must exist before this function is called. # target must exist before this function is called.
function (setup_aom_util_targets) function (setup_aom_util_targets)
add_library(aom_util OBJECT ${AOM_UTIL_SOURCES}) add_library(aom_util STATIC ${AOM_UTIL_SOURCES})
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_util PARENT_SCOPE) set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_util PARENT_SCOPE)
target_sources(aom PUBLIC $<TARGET_OBJECTS:aom_util>) target_link_libraries(aom PRIVATE aom_util)
endfunction () endfunction ()
endif () # AOM_AOM_UTIL_AOM_UTIL_CMAKE_ endif () # AOM_AOM_UTIL_AOM_UTIL_CMAKE_
...@@ -442,75 +442,82 @@ endif () ...@@ -442,75 +442,82 @@ endif ()
# this function is called. # this function is called.
function (setup_av1_targets) function (setup_av1_targets)
add_library(aom_av1_common OBJECT ${AOM_AV1_COMMON_SOURCES}) add_library(aom_av1_common OBJECT ${AOM_AV1_COMMON_SOURCES})
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_av1_common) list(APPEND AOM_LIB_TARGETS aom_av1_common)
target_sources(aom PUBLIC $<TARGET_OBJECTS:aom_av1_common>) add_library(aom_av1 STATIC $<TARGET_OBJECTS:aom_av1_common>)
list(APPEND AOM_LIB_TARGETS aom_av1)
# Not all generators support libraries consisting only of object files. Add a
# dummy source file to the aom_av1 target.
add_dummy_source_file_to_target("aom_av1" "c")
if (CONFIG_AV1_DECODER) if (CONFIG_AV1_DECODER)
add_library(aom_av1_decoder OBJECT ${AOM_AV1_DECODER_SOURCES}) add_library(aom_av1_decoder OBJECT ${AOM_AV1_DECODER_SOURCES})
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_av1_decoder) set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_av1_decoder)
target_sources(aom PUBLIC $<TARGET_OBJECTS:aom_av1_decoder>) target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_av1_decoder>)
endif () endif ()
if (CONFIG_AV1_ENCODER) if (CONFIG_AV1_ENCODER)
add_library(aom_av1_encoder OBJECT ${AOM_AV1_ENCODER_SOURCES}) add_library(aom_av1_encoder OBJECT ${AOM_AV1_ENCODER_SOURCES})
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_av1_encoder) set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_av1_encoder)
target_sources(aom PUBLIC $<TARGET_OBJECTS:aom_av1_encoder>) target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_av1_encoder>)
endif () endif ()
if (HAVE_SSE2) if (HAVE_SSE2)
require_flag_nomsvc("-msse2" NO) require_flag_nomsvc("-msse2" NO)
add_intrinsics_object_library("-msse2" "sse2" "aom_av1_common" add_intrinsics_object_library("-msse2" "sse2" "aom_av1_common"
"AOM_AV1_COMMON_INTRIN_SSE2") "AOM_AV1_COMMON_INTRIN_SSE2" "aom_av1")
if (CONFIG_AV1_DECODER) if (CONFIG_AV1_DECODER)
if (AOM_AV1_DECODER_ASM_SSE2) if (AOM_AV1_DECODER_ASM_SSE2)
add_asm_library("aom_av1_decoder_sse2" "AOM_AV1_DECODER_ASM_SSE2" "aom") add_asm_library("aom_av1_decoder_sse2" "AOM_AV1_DECODER_ASM_SSE2"
"aom_av1")
endif () endif ()
if (AOM_AV1_DECODER_INTRIN_SSE2) if (AOM_AV1_DECODER_INTRIN_SSE2)
add_intrinsics_object_library("-msse2" "sse2" "aom_av1_decoder" add_intrinsics_object_library("-msse2" "sse2" "aom_av1_decoder"
"AOM_AV1_DECODER_INTRIN_SSE2") "AOM_AV1_DECODER_INTRIN_SSE2" "aom_av1")
endif () endif ()
endif () endif ()
if (CONFIG_AV1_ENCODER) if (CONFIG_AV1_ENCODER)
add_asm_library("aom_av1_encoder_sse2" "AOM_AV1_ENCODER_ASM_SSE2" "aom") add_asm_library("aom_av1_encoder_sse2" "AOM_AV1_ENCODER_ASM_SSE2"
"aom_av1")
add_intrinsics_object_library("-msse2" "sse2" "aom_av1_encoder" add_intrinsics_object_library("-msse2" "sse2" "aom_av1_encoder"
"AOM_AV1_ENCODER_INTRIN_SSE2") "AOM_AV1_ENCODER_INTRIN_SSE2" "aom_av1")
endif () endif ()
endif () endif ()
if (HAVE_SSSE3) if (HAVE_SSSE3)
require_flag_nomsvc("-mssse3" NO) require_flag_nomsvc("-mssse3" NO)
add_intrinsics_object_library("-mssse3" "ssse3" "aom_av1_common" add_intrinsics_object_library("-mssse3" "ssse3" "aom_av1_common"
"AOM_AV1_COMMON_INTRIN_SSSE3") "AOM_AV1_COMMON_INTRIN_SSSE3" "aom_av1")
if (CONFIG_AV1_DECODER) if (CONFIG_AV1_DECODER)
if (AOM_AV1_DECODER_INTRIN_SSSE3) if (AOM_AV1_DECODER_INTRIN_SSSE3)
add_intrinsics_object_library("-mssse3" "ssse3" "aom_av1_decoder" add_intrinsics_object_library("-mssse3" "ssse3" "aom_av1_decoder"
"AOM_AV1_DECODER_INTRIN_SSSE3") "AOM_AV1_DECODER_INTRIN_SSSE3" "aom_av1")
endif () endif ()
endif () endif ()
if (CONFIG_AV1_ENCODER) if (CONFIG_AV1_ENCODER)
add_intrinsics_object_library("-mssse3" "ssse3" "aom_av1_encoder" add_intrinsics_object_library("-mssse3" "ssse3" "aom_av1_encoder"
"AOM_AV1_ENCODER_INTRIN_SSSE3") "AOM_AV1_ENCODER_INTRIN_SSSE3" "aom_av1")
endif () endif ()
endif () endif ()
if (HAVE_SSE4_1) if (HAVE_SSE4_1)
require_flag_nomsvc("-msse4.1" NO) require_flag_nomsvc("-msse4.1" NO)
add_intrinsics_object_library("-msse4.1" "sse4" "aom_av1_common" add_intrinsics_object_library("-msse4.1" "sse4" "aom_av1_common"
"AOM_AV1_COMMON_INTRIN_SSE4_1") "AOM_AV1_COMMON_INTRIN_SSE4_1" "aom_av1")
if (CONFIG_AV1_ENCODER) if (CONFIG_AV1_ENCODER)
if ("${AOM_TARGET_CPU}" STREQUAL "x86_64") if ("${AOM_TARGET_CPU}" STREQUAL "x86_64")
add_asm_library("aom_av1_encoder_ssse3" add_asm_library("aom_av1_encoder_ssse3"
"AOM_AV1_ENCODER_ASM_SSSE3_X86_64" "aom") "AOM_AV1_ENCODER_ASM_SSSE3_X86_64" "aom_av1")
endif () endif ()
if (AOM_AV1_ENCODER_INTRIN_SSE4_1) if (AOM_AV1_ENCODER_INTRIN_SSE4_1)
add_intrinsics_object_library("-msse4.1" "sse4" "aom_av1_encoder" add_intrinsics_object_library("-msse4.1" "sse4" "aom_av1_encoder"
"AOM_AV1_ENCODER_INTRIN_SSE4_1") "AOM_AV1_ENCODER_INTRIN_SSE4_1" "aom_av1")
endif () endif ()
endif () endif ()
endif () endif ()
...@@ -518,11 +525,11 @@ function (setup_av1_targets) ...@@ -518,11 +525,11 @@ function (setup_av1_targets)
if (HAVE_AVX2) if (HAVE_AVX2)
require_flag_nomsvc("-mavx2" NO) require_flag_nomsvc("-mavx2" NO)
add_intrinsics_object_library("-mavx2" "avx2" "aom_av1_common" add_intrinsics_object_library("-mavx2" "avx2" "aom_av1_common"
"AOM_AV1_COMMON_INTRIN_AVX2") "AOM_AV1_COMMON_INTRIN_AVX2" "aom_av1")
if (CONFIG_AV1_ENCODER) if (CONFIG_AV1_ENCODER)
add_intrinsics_object_library("-mavx2" "avx2" "aom_av1_encoder" add_intrinsics_object_library("-mavx2" "avx2" "aom_av1_encoder"
"AOM_AV1_ENCODER_INTRIN_AVX2") "AOM_AV1_ENCODER_INTRIN_AVX2" "aom_av1")
endif () endif ()
endif () endif ()
...@@ -531,29 +538,32 @@ function (setup_av1_targets) ...@@ -531,29 +538,32 @@ function (setup_av1_targets)
add_intrinsics_object_library("${AOM_INTRIN_NEON_FLAG}" add_intrinsics_object_library("${AOM_INTRIN_NEON_FLAG}"
"neon" "neon"
"aom_av1_common" "aom_av1_common"
"AOM_AV1_COMMON_INTRIN_NEON") "AOM_AV1_COMMON_INTRIN_NEON" "aom_av1")
endif () endif ()
if (AOM_AV1_ENCODER_INTRIN_NEON) if (AOM_AV1_ENCODER_INTRIN_NEON)
add_intrinsics_object_library("${AOM_INTRIN_NEON_FLAG}" add_intrinsics_object_library("${AOM_INTRIN_NEON_FLAG}"
"neon" "neon"
"aom_av1_encoder" "aom_av1_encoder"
"AOM_AV1_ENCODER_INTRIN_NEON") "AOM_AV1_ENCODER_INTRIN_NEON" "aom_av1")
endif () endif ()
endif () endif ()
if (HAVE_DSPR2) if (HAVE_DSPR2)
add_intrinsics_object_library("" "dspr2" "aom_av1_common" add_intrinsics_object_library("" "dspr2" "aom_av1_common"
"AOM_AV1_COMMON_INTRIN_DSPR2") "AOM_AV1_COMMON_INTRIN_DSPR2" "aom_av1")
endif () endif ()
if (HAVE_MSA) if (HAVE_MSA)
add_intrinsics_object_library("" "msa" "aom_av1_common" add_intrinsics_object_library("" "msa" "aom_av1_common"
"AOM_AV1_COMMON_INTRIN_MSA") "AOM_AV1_COMMON_INTRIN_MSA" "aom_av1")
add_intrinsics_object_library("" "msa" "aom_av1_encoder" add_intrinsics_object_library("" "msa" "aom_av1_encoder"
"AOM_AV1_ENCODER_INTRIN_MSA") "AOM_AV1_ENCODER_INTRIN_MSA" "aom_av1")
endif () endif ()
target_link_libraries(aom_av1 PRIVATE aom_dsp aom_scale)
target_link_libraries(aom PRIVATE aom_av1)
# Pass the new lib targets up to the parent scope instance of # Pass the new lib targets up to the parent scope instance of
# $AOM_LIB_TARGETS. # $AOM_LIB_TARGETS.
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} PARENT_SCOPE) set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} PARENT_SCOPE)
...