Commit 78516fca authored by Tom Finegan's avatar Tom Finegan

Build static libaom without internal deps in CMake.

Change the internal lib targets so that external apps
need link only libaom instead of all internal library
targets and libaom.

BUG=aomedia:76,aomedia:609

Change-Id: I38862fcd90cb585300b6b23e8558f78a1934750f
parent b962dbb2
......@@ -415,7 +415,9 @@ endif ()
function (setup_aom_dsp_targets)
add_library(aom_dsp_common OBJECT ${AOM_DSP_COMMON_SOURCES})
list(APPEND AOM_LIB_TARGETS aom_dsp_common)
add_library(aom_dsp STATIC $<TARGET_OBJECTS:aom_dsp_common>)
create_dummy_source_file("aom_av1" "c" "dummy_source_file")
add_library(aom_dsp OBJECT "${dummy_source_file}")
target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_dsp_common>)
list(APPEND AOM_LIB_TARGETS aom_dsp)
# Not all generators support libraries consisting only of object files. Add a
......@@ -425,112 +427,107 @@ function (setup_aom_dsp_targets)
if (CONFIG_AV1_DECODER)
add_library(aom_dsp_decoder OBJECT ${AOM_DSP_DECODER_SOURCES})
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_dsp_decoder)
target_sources(aom_dsp PRIVATE $<TARGET_OBJECTS:aom_dsp_decoder>)
target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_dsp_decoder>)
endif ()
if (CONFIG_AV1_ENCODER)
add_library(aom_dsp_encoder OBJECT ${AOM_DSP_ENCODER_SOURCES})
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_dsp_encoder)
target_sources(aom_dsp PRIVATE $<TARGET_OBJECTS:aom_dsp_encoder>)
target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_dsp_encoder>)
endif ()
if (HAVE_SSE2)
add_asm_library("aom_dsp_common_sse2" "AOM_DSP_COMMON_ASM_SSE2" "aom_dsp")
add_asm_library("aom_dsp_common_sse2" "AOM_DSP_COMMON_ASM_SSE2" "aom")
add_intrinsics_object_library("-msse2" "sse2" "aom_dsp_common"
"AOM_DSP_COMMON_INTRIN_SSE2" "aom_dsp")
"AOM_DSP_COMMON_INTRIN_SSE2" "aom")
if (CONFIG_AV1_ENCODER)
add_asm_library("aom_dsp_encoder_sse2" "AOM_DSP_ENCODER_ASM_SSE2"
"aom_dsp")
"aom")
add_intrinsics_object_library("-msse2" "sse2" "aom_dsp_encoder"
"AOM_DSP_ENCODER_INTRIN_SSE2" "aom_dsp")
"AOM_DSP_ENCODER_INTRIN_SSE2" "aom")
endif()
endif ()
if (HAVE_SSE3 AND CONFIG_AV1_ENCODER)
add_asm_library("aom_dsp_encoder_sse3" "AOM_DSP_ENCODER_INTRIN_SSE3"
"aom_dsp")
add_asm_library("aom_dsp_encoder_sse3" "AOM_DSP_ENCODER_INTRIN_SSE3" "aom")
endif ()
if (HAVE_SSSE3)
add_asm_library("aom_dsp_common_ssse3" "AOM_DSP_COMMON_ASM_SSSE3" "aom_dsp")
add_asm_library("aom_dsp_common_ssse3" "AOM_DSP_COMMON_ASM_SSSE3" "aom")
add_intrinsics_object_library("-mssse3" "ssse3" "aom_dsp_common"
"AOM_DSP_COMMON_INTRIN_SSSE3" "aom_dsp")
"AOM_DSP_COMMON_INTRIN_SSSE3" "aom")
if (CONFIG_AV1_ENCODER)
if ("${AOM_TARGET_CPU}" STREQUAL "x86_64")
list(APPEND AOM_DSP_ENCODER_ASM_SSSE3
${AOM_DSP_ENCODER_ASM_SSSE3_X86_64})
endif ()
add_asm_library("aom_dsp_encoder_ssse3" "AOM_DSP_ENCODER_ASM_SSSE3"
"aom_dsp")
add_asm_library("aom_dsp_encoder_ssse3" "AOM_DSP_ENCODER_ASM_SSSE3" "aom")
if (AOM_DSP_ENCODER_INTRIN_SSSE3)
add_intrinsics_object_library("-mssse3" "ssse3" "aom_dsp_encoder"
"AOM_DSP_ENCODER_INTRIN_SSSE3" "aom_dsp")
"AOM_DSP_ENCODER_INTRIN_SSSE3" "aom")
endif ()
endif ()
endif ()
if (HAVE_SSE4_1)
add_intrinsics_object_library("-msse4.1" "sse4_1" "aom_dsp_common"
"AOM_DSP_COMMON_INTRIN_SSE4_1" "aom_dsp")
"AOM_DSP_COMMON_INTRIN_SSE4_1" "aom")
if (CONFIG_AV1_ENCODER)
if (AOM_DSP_ENCODER_INTRIN_SSE4_1)
add_intrinsics_object_library("-msse4.1" "sse4_1" "aom_dsp_encoder"
"AOM_DSP_ENCODER_INTRIN_SSE4_1" "aom_dsp")
"AOM_DSP_ENCODER_INTRIN_SSE4_1" "aom")
endif ()
add_asm_library("aom_dsp_encoder_sse4_1" "AOM_DSP_ENCODER_ASM_SSE4_1"
"aom_dsp")
"aom")
endif ()
endif ()
if (HAVE_AVX AND "${AOM_TARGET_CPU}" STREQUAL "x86_64")
if (CONFIG_AV1_ENCODER)
add_asm_library("aom_dsp_encoder_avx" "AOM_DSP_ENCODER_AVX_ASM_X86_64"
"aom_dsp")
"aom")
endif ()
endif ()
if (HAVE_AVX2)
add_intrinsics_object_library("-mavx2" "avx2" "aom_dsp_common"
"AOM_DSP_COMMON_INTRIN_AVX2" "aom_dsp")
"AOM_DSP_COMMON_INTRIN_AVX2" "aom")
if (CONFIG_AV1_ENCODER)
add_intrinsics_object_library("-mavx2" "avx2" "aom_dsp_encoder"
"AOM_DSP_ENCODER_INTRIN_AVX2" "aom_dsp")
"AOM_DSP_ENCODER_INTRIN_AVX2" "aom")
endif ()
endif ()
if (HAVE_NEON_ASM)
if (AOM_ADS2GAS_REQUIRED)
add_gas_asm_library("aom_dsp_common_neon" "AOM_DSP_COMMON_ASM_NEON"
"aom_dsp")
add_gas_asm_library("aom_dsp_common_neon" "AOM_DSP_COMMON_ASM_NEON" "aom")
else ()
add_asm_library("aom_dsp_common_neon" "AOM_DSP_COMMON_ASM_NEON" "aom_dsp")
add_asm_library("aom_dsp_common_neon" "AOM_DSP_COMMON_ASM_NEON" "aom")
endif ()
endif ()
if (HAVE_NEON)
add_intrinsics_object_library("${AOM_NEON_INTRIN_FLAG}" "neon"
"aom_dsp_common" "AOM_DSP_COMMON_INTRIN_NEON"
"aom_dsp")
"aom")
endif ()
if (HAVE_DSPR2)
add_intrinsics_object_library("" "dspr2" "aom_dsp_common"
"AOM_DSP_COMMON_INTRIN_DSPR2" "aom_dsp")
"AOM_DSP_COMMON_INTRIN_DSPR2" "aom")
endif ()
if (HAVE_MSA)
add_intrinsics_object_library("" "msa" "aom_dsp_common"
"AOM_DSP_COMMON_INTRIN_MSA" "aom_dsp")
"AOM_DSP_COMMON_INTRIN_MSA" "aom")
if (CONFIG_AV1_ENCODER)
add_intrinsics_object_library("" "msa" "aom_dsp_encoder"
"AOM_DSP_ENCODER_INTRIN_MSA" "aom_dsp")
"AOM_DSP_ENCODER_INTRIN_MSA" "aom")
endif ()
endif ()
target_link_libraries(aom PRIVATE aom_dsp)
# Pass the new lib targets up to the parent scope instance of
# $AOM_LIB_TARGETS.
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} PARENT_SCOPE)
......
......@@ -19,9 +19,9 @@ set(AOM_MEM_SOURCES
# Creates the aom_mem build target and makes libaom depend on it. The libaom
# target must exist before this function is called.
function (setup_aom_mem_targets)
add_library(aom_mem STATIC ${AOM_MEM_SOURCES})
add_library(aom_mem OBJECT ${AOM_MEM_SOURCES})
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_mem PARENT_SCOPE)
target_link_libraries(aom PRIVATE aom_mem)
target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_mem>)
endfunction ()
endif () # AOM_AOM_MEM_AOM_MEM_CMAKE_
......@@ -43,9 +43,9 @@ function (setup_aom_ports_targets)
add_asm_library("aom_ports" "AOM_PORTS_ASM_MMX" "aom")
set(aom_ports_has_symbols 1)
elseif ("${AOM_TARGET_CPU}" MATCHES "arm")
add_library(aom_ports STATIC ${AOM_PORTS_SOURCES_ARM})
add_library(aom_ports OBJECT ${AOM_PORTS_SOURCES_ARM})
set(aom_ports_has_symbols 1)
target_link_libraries(aom PRIVATE aom_ports)
target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_ports>)
endif ()
if (aom_ports_has_symbols)
......
......@@ -25,8 +25,8 @@ set(AOM_SCALE_INTRIN_DSPR2
# Creates the aom_scale build target and makes libaom depend on it. The libaom
# target must exist before this function is called.
function (setup_aom_scale_targets)
add_library(aom_scale STATIC ${AOM_SCALE_SOURCES})
target_link_libraries(aom PRIVATE aom_scale)
add_library(aom_scale OBJECT ${AOM_SCALE_SOURCES})
target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_scale>)
if (HAVE_DSPR2)
add_intrinsics_object_library("" "dspr2" "aom_scale"
......
......@@ -26,9 +26,9 @@ endif ()
# Creates the aom_util build target and makes libaom depend on it. The libaom
# target must exist before this function is called.
function (setup_aom_util_targets)
add_library(aom_util STATIC ${AOM_UTIL_SOURCES})
add_library(aom_util OBJECT ${AOM_UTIL_SOURCES})
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_util PARENT_SCOPE)
target_link_libraries(aom PRIVATE aom_util)
target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_util>)
endfunction ()
endif () # AOM_AOM_UTIL_AOM_UTIL_CMAKE_
......@@ -443,7 +443,10 @@ endif ()
function (setup_av1_targets)
add_library(aom_av1_common OBJECT ${AOM_AV1_COMMON_SOURCES})
list(APPEND AOM_LIB_TARGETS aom_av1_common)
add_library(aom_av1 STATIC $<TARGET_OBJECTS:aom_av1_common>)
create_dummy_source_file("aom_av1" "c" "dummy_source_file")
add_library(aom_av1 OBJECT "${dummy_source_file}")
target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_av1_common>)
list(APPEND AOM_LIB_TARGETS aom_av1)
# Not all generators support libraries consisting only of object files. Add a
......@@ -465,59 +468,57 @@ function (setup_av1_targets)
if (HAVE_SSE2)
require_flag_nomsvc("-msse2" NO)
add_intrinsics_object_library("-msse2" "sse2" "aom_av1_common"
"AOM_AV1_COMMON_INTRIN_SSE2" "aom_av1")
"AOM_AV1_COMMON_INTRIN_SSE2" "aom")
if (CONFIG_AV1_DECODER)
if (AOM_AV1_DECODER_ASM_SSE2)
add_asm_library("aom_av1_decoder_sse2" "AOM_AV1_DECODER_ASM_SSE2"
"aom_av1")
add_asm_library("aom_av1_decoder_sse2" "AOM_AV1_DECODER_ASM_SSE2" "aom")
endif ()
if (AOM_AV1_DECODER_INTRIN_SSE2)
add_intrinsics_object_library("-msse2" "sse2" "aom_av1_decoder"
"AOM_AV1_DECODER_INTRIN_SSE2" "aom_av1")
"AOM_AV1_DECODER_INTRIN_SSE2" "aom")
endif ()
endif ()
if (CONFIG_AV1_ENCODER)
add_asm_library("aom_av1_encoder_sse2" "AOM_AV1_ENCODER_ASM_SSE2"
"aom_av1")
add_asm_library("aom_av1_encoder_sse2" "AOM_AV1_ENCODER_ASM_SSE2" "aom")
add_intrinsics_object_library("-msse2" "sse2" "aom_av1_encoder"
"AOM_AV1_ENCODER_INTRIN_SSE2" "aom_av1")
"AOM_AV1_ENCODER_INTRIN_SSE2" "aom")
endif ()
endif ()
if (HAVE_SSSE3)
require_flag_nomsvc("-mssse3" NO)
add_intrinsics_object_library("-mssse3" "ssse3" "aom_av1_common"
"AOM_AV1_COMMON_INTRIN_SSSE3" "aom_av1")
"AOM_AV1_COMMON_INTRIN_SSSE3" "aom")
if (CONFIG_AV1_DECODER)
if (AOM_AV1_DECODER_INTRIN_SSSE3)
add_intrinsics_object_library("-mssse3" "ssse3" "aom_av1_decoder"
"AOM_AV1_DECODER_INTRIN_SSSE3" "aom_av1")
"AOM_AV1_DECODER_INTRIN_SSSE3" "aom")
endif ()
endif ()
if (CONFIG_AV1_ENCODER)
add_intrinsics_object_library("-mssse3" "ssse3" "aom_av1_encoder"
"AOM_AV1_ENCODER_INTRIN_SSSE3" "aom_av1")
"AOM_AV1_ENCODER_INTRIN_SSSE3" "aom")
endif ()
endif ()
if (HAVE_SSE4_1)
require_flag_nomsvc("-msse4.1" NO)
add_intrinsics_object_library("-msse4.1" "sse4" "aom_av1_common"
"AOM_AV1_COMMON_INTRIN_SSE4_1" "aom_av1")
"AOM_AV1_COMMON_INTRIN_SSE4_1" "aom")
if (CONFIG_AV1_ENCODER)
if ("${AOM_TARGET_CPU}" STREQUAL "x86_64")
add_asm_library("aom_av1_encoder_ssse3"
"AOM_AV1_ENCODER_ASM_SSSE3_X86_64" "aom_av1")
"AOM_AV1_ENCODER_ASM_SSSE3_X86_64" "aom")
endif ()
if (AOM_AV1_ENCODER_INTRIN_SSE4_1)
add_intrinsics_object_library("-msse4.1" "sse4" "aom_av1_encoder"
"AOM_AV1_ENCODER_INTRIN_SSE4_1" "aom_av1")
"AOM_AV1_ENCODER_INTRIN_SSE4_1" "aom")
endif ()
endif ()
endif ()
......@@ -525,11 +526,11 @@ function (setup_av1_targets)
if (HAVE_AVX2)
require_flag_nomsvc("-mavx2" NO)
add_intrinsics_object_library("-mavx2" "avx2" "aom_av1_common"
"AOM_AV1_COMMON_INTRIN_AVX2" "aom_av1")
"AOM_AV1_COMMON_INTRIN_AVX2" "aom")
if (CONFIG_AV1_ENCODER)
add_intrinsics_object_library("-mavx2" "avx2" "aom_av1_encoder"
"AOM_AV1_ENCODER_INTRIN_AVX2" "aom_av1")
"AOM_AV1_ENCODER_INTRIN_AVX2" "aom")
endif ()
endif ()
......@@ -538,31 +539,31 @@ function (setup_av1_targets)
add_intrinsics_object_library("${AOM_INTRIN_NEON_FLAG}"
"neon"
"aom_av1_common"
"AOM_AV1_COMMON_INTRIN_NEON" "aom_av1")
"AOM_AV1_COMMON_INTRIN_NEON" "aom")
endif ()
if (AOM_AV1_ENCODER_INTRIN_NEON)
add_intrinsics_object_library("${AOM_INTRIN_NEON_FLAG}"
"neon"
"aom_av1_encoder"
"AOM_AV1_ENCODER_INTRIN_NEON" "aom_av1")
"AOM_AV1_ENCODER_INTRIN_NEON" "aom")
endif ()
endif ()
if (HAVE_DSPR2)
add_intrinsics_object_library("" "dspr2" "aom_av1_common"
"AOM_AV1_COMMON_INTRIN_DSPR2" "aom_av1")
"AOM_AV1_COMMON_INTRIN_DSPR2" "aom")
endif ()
if (HAVE_MSA)
add_intrinsics_object_library("" "msa" "aom_av1_common"
"AOM_AV1_COMMON_INTRIN_MSA" "aom_av1")
"AOM_AV1_COMMON_INTRIN_MSA" "aom")
add_intrinsics_object_library("" "msa" "aom_av1_encoder"
"AOM_AV1_ENCODER_INTRIN_MSA" "aom_av1")
"AOM_AV1_ENCODER_INTRIN_MSA" "aom")
endif ()
target_link_libraries(aom_av1 PRIVATE aom_dsp aom_scale)
target_link_libraries(aom PRIVATE aom_av1)
target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_dsp>)
target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_scale>)
# Pass the new lib targets up to the parent scope instance of
# $AOM_LIB_TARGETS.
......
......@@ -131,7 +131,7 @@ function (add_asm_library lib_name asm_sources dependent_target)
COMMENT "Building ASM object ${asm_object}"
WORKING_DIRECTORY "${AOM_CONFIG_DIR}"
VERBATIM)
target_sources(${lib_name} PRIVATE "${asm_object}")
target_sources(aom PRIVATE "${asm_object}")
endforeach ()
# The above created a target containing only ASM sources. Cmake needs help
......@@ -141,8 +141,6 @@ function (add_asm_library lib_name asm_sources dependent_target)
# at you, xcode generator).
add_dummy_source_file_to_target("${lib_name}" "c")
target_link_libraries(${dependent_target} PRIVATE ${lib_name})
# Add the new lib target to the global list of aom library targets.
list(APPEND AOM_LIB_TARGETS ${lib_name})
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} PARENT_SCOPE)
......
......@@ -11,13 +11,18 @@
if (NOT AOM_BUILD_CMAKE_UTIL_CMAKE_)
set(AOM_BUILD_CMAKE_UTIL_CMAKE_ 1)
function (add_dummy_source_file_to_target target_name extension)
set(dummy_source_file "${AOM_CONFIG_DIR}/${target_name}_dummy.${extension}")
file(WRITE "${dummy_source_file}"
function (create_dummy_source_file basename extension out_file_path)
set(dummy_source_file "${AOM_CONFIG_DIR}/${basename}.${extension}")
file(WRITE "${dummy_source_file}"
"// Generated file. DO NOT EDIT!\n"
"// ${target_name} needs a ${extension} file to force link language, \n"
"// ignore me.\n"
"// or to silence a harmless CMake warning: Ignore me.\n"
"void ${target_name}_dummy_function(void) {}\n")
set(${out_file_path} ${dummy_source_file} PARENT_SCOPE)
endfunction ()
function (add_dummy_source_file_to_target target_name extension)
create_dummy_source_file("${target_name}" "${extension}" "dummy_source_file")
target_sources(${target_name} PRIVATE ${dummy_source_file})
endfunction ()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment