Tom Finegan | 84f2d79 | 2017-06-15 23:06:44 -0700 | [diff] [blame^] | 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 | ## |
| 11 | if (NOT AOM_BUILD_CMAKE_EXPORTS_CMAKE_) |
| 12 | set(AOM_BUILD_CMAKE_EXPORTS_CMAKE_ 1) |
| 13 | |
| 14 | include("${AOM_ROOT}/build/cmake/exports_sources.cmake") |
| 15 | |
| 16 | # Creates the custom target which handles generation of the symbol export lists. |
| 17 | function (setup_exports_target) |
| 18 | if ("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin") |
| 19 | set(symbol_file_ext "syms") |
| 20 | elseif ("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS" AND MSVC) |
| 21 | set(symbol_file_ext "def") |
| 22 | else () |
| 23 | set(symbol_file_ext "ver") |
| 24 | endif () |
| 25 | |
| 26 | set(aom_sym_file "${AOM_CONFIG_DIR}/libaom.${symbol_file_ext}") |
| 27 | |
| 28 | add_custom_target(generate_exports |
| 29 | COMMAND ${CMAKE_COMMAND} |
| 30 | -DAOM_ROOT="${AOM_ROOT}" |
| 31 | -DAOM_CONFIG_DIR="${AOM_CONFIG_DIR}" |
| 32 | -DAOM_TARGET_SYSTEM=${AOM_TARGET_SYSTEM} |
| 33 | -DAOM_SYM_FILE="${aom_sym_file}" |
| 34 | -DAOM_MSVC=${MSVC} |
| 35 | -DAOM_XCODE=${XCODE} |
| 36 | -DCONFIG_NAME=$<CONFIG> |
| 37 | -DCONFIG_AV1_DECODER=${CONFIG_AV1_DECODER} |
| 38 | -DCONFIG_AV1_ENCODER=${CONFIG_AV1_ENCODER} |
| 39 | -P "${AOM_ROOT}/build/cmake/generate_exports.cmake" |
| 40 | SOURCES ${AOM_EXPORTS_SOURCES} |
| 41 | DEPENDS ${AOM_EXPORTS_SOURCES}) |
| 42 | |
| 43 | # Make libaom depend on the exports file, and set flags to pick it up when |
| 44 | # creating the dylib. |
| 45 | add_dependencies(aom generate_exports) |
| 46 | |
| 47 | if (APPLE) |
| 48 | set_property(TARGET aom APPEND_STRING PROPERTY LINK_FLAGS |
| 49 | "-exported_symbols_list ${aom_sym_file}") |
| 50 | elseif (WIN32) |
| 51 | message(FATAL_ERROR "Windows DLL builds not supported yet.") |
| 52 | if (NOT MSVC) |
| 53 | set_property(TARGET aom APPEND_STRING PROPERTY LINK_FLAGS |
| 54 | "-Wl,--version-script ${aom_sym_file}") |
| 55 | endif () |
| 56 | |
| 57 | # TODO(tomfinegan): Sort out the import lib situation and flags for MSVC. |
| 58 | |
| 59 | else () |
| 60 | set_property(TARGET aom APPEND_STRING PROPERTY LINK_FLAGS |
| 61 | "-Wl,--version-script,${aom_sym_file}") |
| 62 | endif () |
| 63 | endfunction () |
| 64 | |
| 65 | endif () # AOM_BUILD_CMAKE_EXPORTS_CMAKE_ |