1##
2## Copyright (c) 2017, Alliance for Open Media. All rights reserved
3##
4## This source code is subject to the terms of the BSD 2 Clause License and
5## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6## was not distributed with this source code in the LICENSE file, you can
7## obtain it at www.aomedia.org/license/software. If the Alliance for Open
8## Media Patent License 1.0 was not distributed with this source code in the
9## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10##
11if (NOT AOM_AOM_PORTS_AOM_PORTS_CMAKE_)
12set(AOM_AOM_PORTS_AOM_PORTS_CMAKE_ 1)
13
14set(AOM_PORTS_INCLUDES
15    "${AOM_ROOT}/aom_ports/aom_once.h"
16    "${AOM_ROOT}/aom_ports/aom_timer.h"
17    "${AOM_ROOT}/aom_ports/bitops.h"
18    "${AOM_ROOT}/aom_ports/emmintrin_compat.h"
19    "${AOM_ROOT}/aom_ports/mem.h"
20    "${AOM_ROOT}/aom_ports/mem_ops.h"
21    "${AOM_ROOT}/aom_ports/mem_ops_aligned.h"
22    "${AOM_ROOT}/aom_ports/msvc.h"
23    "${AOM_ROOT}/aom_ports/system_state.h")
24
25set(AOM_PORTS_ASM_X86 "${AOM_ROOT}/aom_ports/emms.asm")
26
27set(AOM_PORTS_INCLUDES_X86
28    "${AOM_ROOT}/aom_ports/x86_abi_support.asm")
29
30set(AOM_PORTS_SOURCES_ARM
31    "${AOM_ROOT}/aom_ports/arm.h"
32    "${AOM_ROOT}/aom_ports/arm_cpudetect.c")
33
34# For arm and x86 targets:
35#   Creates the aom_ports build target, adds the includes in aom_ports to the
36#   target, and makes libaom depend on it.
37# Otherwise:
38#   Adds the includes in aom_ports to the libaom target.
39# For all target platforms:
40#   The libaom target must exist before this function is called.
41function (setup_aom_ports_targets)
42  if ("${AOM_TARGET_CPU}" MATCHES "^x86")
43    add_asm_library("aom_ports" "AOM_PORTS_ASM_X86" "aom")
44    set(aom_ports_has_symbols 1)
45  elseif ("${AOM_TARGET_CPU}" MATCHES "arm")
46    add_library(aom_ports OBJECT ${AOM_PORTS_SOURCES_ARM})
47    set(aom_ports_has_symbols 1)
48    target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_ports>)
49  endif ()
50
51  if (aom_ports_has_symbols)
52    target_sources(aom_ports PRIVATE ${AOM_PORTS_INCLUDES})
53
54    if ("${AOM_TARGET_CPU}" STREQUAL "x86" OR
55        "${AOM_TARGET_CPU}" STREQUAL "x86_64")
56      target_sources(aom_ports PRIVATE ${AOM_PORTS_INCLUDES_X86})
57    endif ()
58
59    set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} PARENT_SCOPE)
60  else ()
61    target_sources(aom PRIVATE ${AOM_PORTS_INCLUDES})
62
63    if ("${AOM_TARGET_CPU}" STREQUAL "x86" OR
64        "${AOM_TARGET_CPU}" STREQUAL "x86_64")
65      target_sources(aom PRIVATE ${AOM_PORTS_INCLUDES_X86})
66    endif ()
67  endif ()
68endfunction ()
69
70endif ()  # AOM_AOM_PORTS_AOM_PORTS_CMAKE_
71