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# 11if(AOM_BUILD_CMAKE_EXPORTS_CMAKE_) 12 return() 13endif() # AOM_BUILD_CMAKE_EXPORTS_CMAKE_ 14set(AOM_BUILD_CMAKE_EXPORTS_CMAKE_ 1) 15 16include("${AOM_ROOT}/build/cmake/exports_sources.cmake") 17 18# Creates the custom target which handles generation of the symbol export lists. 19function(setup_exports_target) 20 if(APPLE) 21 set(symbol_file_ext "syms") 22 elseif(WIN32) 23 set(symbol_file_ext "def") 24 else() 25 set(symbol_file_ext "ver") 26 endif() 27 28 set(aom_sym_file "${AOM_CONFIG_DIR}/libaom.${symbol_file_ext}") 29 30 add_custom_target( 31 generate_exports 32 COMMAND ${CMAKE_COMMAND} 33 -DAOM_ROOT="${AOM_ROOT}" 34 -DAOM_CONFIG_DIR="${AOM_CONFIG_DIR}" 35 -DAOM_TARGET_SYSTEM=${AOM_TARGET_SYSTEM} 36 -DAOM_SYM_FILE="${aom_sym_file}" 37 -DAOM_MSVC=${MSVC} 38 -DAOM_XCODE=${XCODE} 39 -DCMAKE_SHARED_LIBRARY_PREFIX="${CMAKE_SHARED_LIBRARY_PREFIX}" 40 -DCONFIG_NAME=$<CONFIG> 41 -DCONFIG_AV1_DECODER=${CONFIG_AV1_DECODER} 42 -DCONFIG_AV1_ENCODER=${CONFIG_AV1_ENCODER} 43 -DCONFIG_INSPECTION=${CONFIG_INSPECTION} 44 -DENABLE_TESTS=${ENABLE_TESTS} 45 -P 46 "${AOM_ROOT}/build/cmake/generate_exports.cmake" 47 SOURCES ${AOM_EXPORTS_SOURCES} 48 DEPENDS ${AOM_EXPORTS_SOURCES} BYPRODUCTS ${aom_sym_file}) 49 50 # Make libaom depend on the exports file, and set flags to pick it up when 51 # creating the dylib. 52 add_dependencies(aom generate_exports) 53 54 if(APPLE) 55 set_property(TARGET aom 56 APPEND_STRING 57 PROPERTY LINK_FLAGS "-exported_symbols_list ${aom_sym_file}") 58 elseif(WIN32) 59 if(MSVC) 60 set_property(TARGET aom 61 APPEND_STRING 62 PROPERTY LINK_FLAGS "/DEF:${aom_sym_file}") 63 else() 64 # For MinGW and MSYS compilers, you can use either version scripts or 65 # module definition files. If the latter, it must be supplied as an 66 # "object". 67 set_property(TARGET aom 68 APPEND_STRING 69 PROPERTY LINK_FLAGS "${aom_sym_file}") 70 endif() 71 else() 72 set_property(TARGET aom 73 APPEND_STRING 74 PROPERTY LINK_FLAGS "-Wl,--version-script,${aom_sym_file}") 75 endif() 76endfunction() 77