generate_exports.cmake (2518B)
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 # 11 cmake_minimum_required(VERSION 3.16) 12 13 # CMAKE_SHARED_LIBRARY_PREFIX can be empty 14 set(REQUIRED_ARGS "AOM_ROOT" "AOM_CONFIG_DIR" "AOM_TARGET_SYSTEM" "AOM_SYM_FILE" 15 "CONFIG_AV1_DECODER" "CONFIG_AV1_ENCODER") 16 17 foreach(arg ${REQUIRED_ARGS}) 18 if("${${arg}}" STREQUAL "") 19 message(FATAL_ERROR "${arg} must not be empty.") 20 endif() 21 endforeach() 22 23 include("${AOM_ROOT}/build/cmake/exports_sources.cmake") 24 25 if("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin") 26 set(symbol_prefix "_") 27 elseif("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS") 28 file(WRITE "${AOM_SYM_FILE}" "LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}aom\n" 29 "EXPORTS\n") 30 else() 31 set(symbol_suffix ";") 32 endif() 33 34 set(aom_sym_file "${AOM_SYM_FILE}") 35 36 if("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin") 37 file(REMOVE "${aom_sym_file}") 38 elseif("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS") 39 file(WRITE "${aom_sym_file}" "LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}aom\n" 40 "EXPORTS\n") 41 else() 42 file(WRITE "${aom_sym_file}" "{\nglobal:\n") 43 endif() 44 45 foreach(export_file ${AOM_EXPORTS_SOURCES}) 46 file(STRINGS "${export_file}" exported_file_data) 47 set(exported_symbols "${exported_symbols} ${exported_file_data};") 48 string(STRIP "${exported_symbols}" exported_symbols) 49 endforeach() 50 51 foreach(exported_symbol ${exported_symbols}) 52 string(STRIP "${exported_symbol}" exported_symbol) 53 if("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS") 54 string(SUBSTRING ${exported_symbol} 0 4 export_type) 55 string(COMPARE EQUAL "${export_type}" "data" is_data) 56 if(is_data) 57 set(symbol_suffix " DATA") 58 else() 59 set(symbol_suffix "") 60 endif() 61 endif() 62 string(REGEX REPLACE "text \|data " "" "exported_symbol" "${exported_symbol}") 63 set(exported_symbol " ${symbol_prefix}${exported_symbol}${symbol_suffix}") 64 file(APPEND "${aom_sym_file}" "${exported_symbol}\n") 65 endforeach() 66 67 if("${aom_sym_file}" MATCHES "ver$") 68 file(APPEND "${aom_sym_file}" " \nlocal:\n *;\n};") 69 endif()