blob: e0bfd12778042bf1dd38e82c97031c2c1fd9a4a5 [file] [log] [blame]
Johann589bae82018-04-27 10:57:44 -07001#
Lester Lu6bc30d62021-12-16 19:13:21 +00002# Copyright (c) 2021, Alliance for Open Media. All rights reserved
Johann589bae82018-04-27 10:57:44 -07003#
Lester Lu6bc30d62021-12-16 19:13:21 +00004# 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/.
Johann589bae82018-04-27 10:57:44 -070010#
11if(AOM_BUILD_CMAKE_EXPORTS_CMAKE_)
Johann29a59732018-04-27 10:51:00 -070012 return()
Johann589bae82018-04-27 10:57:44 -070013endif() # AOM_BUILD_CMAKE_EXPORTS_CMAKE_
Tom Finegan84f2d792017-06-15 23:06:44 -070014set(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.
Johann589bae82018-04-27 10:57:44 -070019function(setup_exports_target)
20 if("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
Tom Finegan84f2d792017-06-15 23:06:44 -070021 set(symbol_file_ext "syms")
Johann589bae82018-04-27 10:57:44 -070022 elseif("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS" AND MSVC)
Tom Finegan84f2d792017-06-15 23:06:44 -070023 set(symbol_file_ext "def")
Johann589bae82018-04-27 10:57:44 -070024 else()
Tom Finegan84f2d792017-06-15 23:06:44 -070025 set(symbol_file_ext "ver")
Johann589bae82018-04-27 10:57:44 -070026 endif()
Tom Finegan84f2d792017-06-15 23:06:44 -070027
28 set(aom_sym_file "${AOM_CONFIG_DIR}/libaom.${symbol_file_ext}")
29
Lester Lu6bc30d62021-12-16 19:13:21 +000030 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 Finegan84f2d792017-06-15 23:06:44 -070043
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
Johann589bae82018-04-27 10:57:44 -070048 if(APPLE)
Lester Lu6bc30d62021-12-16 19:13:21 +000049 set_property(
50 TARGET aom
51 APPEND_STRING
52 PROPERTY LINK_FLAGS "-exported_symbols_list ${aom_sym_file}")
Johann589bae82018-04-27 10:57:44 -070053 elseif(WIN32)
Johann589bae82018-04-27 10:57:44 -070054 if(NOT MSVC)
Lester Lu6bc30d62021-12-16 19:13:21 +000055 set_property(
56 TARGET aom
57 APPEND_STRING
58 PROPERTY LINK_FLAGS "-Wl,--version-script ${aom_sym_file}")
Ilie Halip0e41f762018-07-16 21:01:43 +030059 else()
Lester Lu6bc30d62021-12-16 19:13:21 +000060 set_property(
61 TARGET aom
62 APPEND_STRING
63 PROPERTY LINK_FLAGS "/DEF:${aom_sym_file}")
Johann589bae82018-04-27 10:57:44 -070064 endif()
Tom Finegan84f2d792017-06-15 23:06:44 -070065
66 # TODO(tomfinegan): Sort out the import lib situation and flags for MSVC.
67
Johann589bae82018-04-27 10:57:44 -070068 else()
Lester Lu6bc30d62021-12-16 19:13:21 +000069 set_property(
70 TARGET aom
71 APPEND_STRING
72 PROPERTY LINK_FLAGS "-Wl,--version-script,${aom_sym_file}")
Johann589bae82018-04-27 10:57:44 -070073 endif()
74endfunction()