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 the
5# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
6# not distributed with this source code in the LICENSE file, you can obtain it
7# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
8# License 1.0 was not distributed with this source code in the PATENTS file, you
9# can obtain it at www.aomedia.org/license/patent.
10#
11cmake_minimum_required(VERSION 3.5)
12
13set(REQUIRED_ARGS "AOM_ROOT" "AOM_CONFIG_DIR" "AOM_TARGET_SYSTEM"
14    "AOM_SYM_FILE" "CONFIG_AV1_DECODER" "CONFIG_AV1_ENCODER")
15
16foreach(arg ${REQUIRED_ARGS})
17  if("${${arg}}" STREQUAL "")
18    message(FATAL_ERROR "${arg} must not be empty.")
19  endif()
20endforeach()
21
22include("${AOM_ROOT}/build/cmake/exports_sources.cmake")
23
24if("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
25  set(symbol_prefix "_")
26elseif("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS" AND AOM_MSVC)
27  file(WRITE "${AOM_SYM_FILE}" "LIBRARY aom\n" "EXPORTS\n")
28else()
29  set(symbol_suffix ";")
30endif()
31
32set(aom_sym_file "${AOM_SYM_FILE}")
33
34if("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
35  file(REMOVE "${aom_sym_file}")
36elseif("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS" AND AOM_MSVC)
37  file(WRITE "${aom_sym_file}" "LIBRARY aom\n" "EXPORTS\n")
38else()
39  file(WRITE "${aom_sym_file}" "{\nglobal:\n")
40endif()
41
42foreach(export_file ${AOM_EXPORTS_SOURCES})
43  file(STRINGS "${export_file}" exported_file_data)
44  set(exported_symbols "${exported_symbols} ${exported_file_data};")
45  string(STRIP "${exported_symbols}" exported_symbols)
46endforeach()
47
48foreach(exported_symbol ${exported_symbols})
49  string(STRIP "${exported_symbol}" exported_symbol)
50  if("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS" AND AOM_MSVC)
51    string(SUBSTRING ${exported_symbol} 0 4 export_type)
52    string(COMPARE EQUAL "${export_type}" "data" is_data)
53    if(is_data)
54      set(symbol_suffix " DATA")
55    else()
56      set(symbol_suffix "")
57    endif()
58  endif()
59  string(REGEX REPLACE "text \|data " "" "exported_symbol" "${exported_symbol}")
60  set(exported_symbol "  ${symbol_prefix}${exported_symbol}${symbol_suffix}")
61  file(APPEND "${aom_sym_file}" "${exported_symbol}\n")
62endforeach()
63
64if("${aom_sym_file}" MATCHES "ver$")
65  file(APPEND "${aom_sym_file}" " \nlocal:\n  *;\n};")
66endif()
67