Johann | 589bae8 | 2018-04-27 10:57:44 -0700 | [diff] [blame] | 1 | # |
Lester Lu | 6bc30d6 | 2021-12-16 19:13:21 +0000 | [diff] [blame^] | 2 | # Copyright (c) 2021, Alliance for Open Media. All rights reserved |
Johann | 589bae8 | 2018-04-27 10:57:44 -0700 | [diff] [blame] | 3 | # |
Lester Lu | 6bc30d6 | 2021-12-16 19:13:21 +0000 | [diff] [blame^] | 4 | # This source code is subject to the terms of the BSD 3-Clause Clear License and |
| 5 | # the Alliance for Open Media Patent License 1.0. If the BSD 3-Clause Clear |
| 6 | # License was not distributed with this source code in the LICENSE file, you can |
| 7 | # obtain it at aomedia.org/license/software-license/bsd-3-c-c/. If the Alliance |
| 8 | # for Open Media Patent License 1.0 was not distributed with this source code in |
| 9 | # the PATENTS file, you can obtain it at aomedia.org/license/patent-license/. |
Johann | 589bae8 | 2018-04-27 10:57:44 -0700 | [diff] [blame] | 10 | # |
| 11 | if(AOM_BUILD_CMAKE_EXPORTS_CMAKE_) |
Johann | 29a5973 | 2018-04-27 10:51:00 -0700 | [diff] [blame] | 12 | return() |
Johann | 589bae8 | 2018-04-27 10:57:44 -0700 | [diff] [blame] | 13 | endif() # AOM_BUILD_CMAKE_EXPORTS_CMAKE_ |
Tom Finegan | 84f2d79 | 2017-06-15 23:06:44 -0700 | [diff] [blame] | 14 | set(AOM_BUILD_CMAKE_EXPORTS_CMAKE_ 1) |
| 15 | |
| 16 | include("${AOM_ROOT}/build/cmake/exports_sources.cmake") |
| 17 | |
| 18 | # Creates the custom target which handles generation of the symbol export lists. |
Johann | 589bae8 | 2018-04-27 10:57:44 -0700 | [diff] [blame] | 19 | function(setup_exports_target) |
| 20 | if("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin") |
Tom Finegan | 84f2d79 | 2017-06-15 23:06:44 -0700 | [diff] [blame] | 21 | set(symbol_file_ext "syms") |
Johann | 589bae8 | 2018-04-27 10:57:44 -0700 | [diff] [blame] | 22 | elseif("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS" AND MSVC) |
Tom Finegan | 84f2d79 | 2017-06-15 23:06:44 -0700 | [diff] [blame] | 23 | set(symbol_file_ext "def") |
Johann | 589bae8 | 2018-04-27 10:57:44 -0700 | [diff] [blame] | 24 | else() |
Tom Finegan | 84f2d79 | 2017-06-15 23:06:44 -0700 | [diff] [blame] | 25 | set(symbol_file_ext "ver") |
Johann | 589bae8 | 2018-04-27 10:57:44 -0700 | [diff] [blame] | 26 | endif() |
Tom Finegan | 84f2d79 | 2017-06-15 23:06:44 -0700 | [diff] [blame] | 27 | |
| 28 | set(aom_sym_file "${AOM_CONFIG_DIR}/libaom.${symbol_file_ext}") |
| 29 | |
Lester Lu | 6bc30d6 | 2021-12-16 19:13:21 +0000 | [diff] [blame^] | 30 | add_custom_target( |
| 31 | generate_exports |
| 32 | COMMAND |
| 33 | ${CMAKE_COMMAND} -DAOM_ROOT="${AOM_ROOT}" |
| 34 | -DAOM_CONFIG_DIR="${AOM_CONFIG_DIR}" |
| 35 | -DAOM_TARGET_SYSTEM=${AOM_TARGET_SYSTEM} -DAOM_SYM_FILE="${aom_sym_file}" |
| 36 | -DAOM_MSVC=${MSVC} -DAOM_XCODE=${XCODE} -DCONFIG_NAME=$<CONFIG> |
| 37 | -DCONFIG_AV1_DECODER=${CONFIG_AV1_DECODER} |
| 38 | -DCONFIG_AV1_ENCODER=${CONFIG_AV1_ENCODER} |
| 39 | -DCONFIG_INSPECTION=${CONFIG_INSPECTION} -DENABLE_TESTS=${ENABLE_TESTS} -P |
| 40 | "${AOM_ROOT}/build/cmake/generate_exports.cmake" |
| 41 | SOURCES ${AOM_EXPORTS_SOURCES} |
| 42 | DEPENDS ${AOM_EXPORTS_SOURCES}) |
Tom Finegan | 84f2d79 | 2017-06-15 23:06:44 -0700 | [diff] [blame] | 43 | |
| 44 | # Make libaom depend on the exports file, and set flags to pick it up when |
| 45 | # creating the dylib. |
| 46 | add_dependencies(aom generate_exports) |
| 47 | |
Johann | 589bae8 | 2018-04-27 10:57:44 -0700 | [diff] [blame] | 48 | if(APPLE) |
Lester Lu | 6bc30d6 | 2021-12-16 19:13:21 +0000 | [diff] [blame^] | 49 | set_property( |
| 50 | TARGET aom |
| 51 | APPEND_STRING |
| 52 | PROPERTY LINK_FLAGS "-exported_symbols_list ${aom_sym_file}") |
Johann | 589bae8 | 2018-04-27 10:57:44 -0700 | [diff] [blame] | 53 | elseif(WIN32) |
Johann | 589bae8 | 2018-04-27 10:57:44 -0700 | [diff] [blame] | 54 | if(NOT MSVC) |
Lester Lu | 6bc30d6 | 2021-12-16 19:13:21 +0000 | [diff] [blame^] | 55 | set_property( |
| 56 | TARGET aom |
| 57 | APPEND_STRING |
| 58 | PROPERTY LINK_FLAGS "-Wl,--version-script ${aom_sym_file}") |
Ilie Halip | 0e41f76 | 2018-07-16 21:01:43 +0300 | [diff] [blame] | 59 | else() |
Lester Lu | 6bc30d6 | 2021-12-16 19:13:21 +0000 | [diff] [blame^] | 60 | set_property( |
| 61 | TARGET aom |
| 62 | APPEND_STRING |
| 63 | PROPERTY LINK_FLAGS "/DEF:${aom_sym_file}") |
Johann | 589bae8 | 2018-04-27 10:57:44 -0700 | [diff] [blame] | 64 | endif() |
Tom Finegan | 84f2d79 | 2017-06-15 23:06:44 -0700 | [diff] [blame] | 65 | |
| 66 | # TODO(tomfinegan): Sort out the import lib situation and flags for MSVC. |
| 67 | |
Johann | 589bae8 | 2018-04-27 10:57:44 -0700 | [diff] [blame] | 68 | else() |
Lester Lu | 6bc30d6 | 2021-12-16 19:13:21 +0000 | [diff] [blame^] | 69 | set_property( |
| 70 | TARGET aom |
| 71 | APPEND_STRING |
| 72 | PROPERTY LINK_FLAGS "-Wl,--version-script,${aom_sym_file}") |
Johann | 589bae8 | 2018-04-27 10:57:44 -0700 | [diff] [blame] | 73 | endif() |
| 74 | endfunction() |