1# Copyright 2020 The SwiftShader Authors. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#    http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15set(LIBBACKTRACE_SRC_FILES
16    src/atomic.c
17    src/backtrace.c
18    src/backtrace.h
19    src/dwarf.c
20    src/fileline.c
21    src/filenames.h
22    src/internal.h
23    src/mmap.c
24    src/mmapio.c
25    src/posix.c
26    src/print.c
27    src/simple.c
28    src/sort.c
29    src/state.c
30    src/backtrace-supported.h
31    src/config.h
32)
33
34if(WIN32)
35    list(APPEND LIBBACKTRACE_SRC_FILES src/pecoff.c)
36elseif(LINUX)
37    list(APPEND LIBBACKTRACE_SRC_FILES src/elf.c)
38    list(APPEND LIBBACKTRACE_PRIVATE_INCLUDE_DIRS "config/linux/include")
39elseif(APPLE)
40    message(FATAL_ERROR "libbacktrace does not support mach-o yet")
41    list(APPEND LIBBACKTRACE_PRIVATE_INCLUDE_DIRS "config/darwin/include")
42endif()
43
44add_library(libbacktrace STATIC EXCLUDE_FROM_ALL
45    ${LIBBACKTRACE_SRC_FILES}
46)
47
48set_target_properties(libbacktrace PROPERTIES
49    POSITION_INDEPENDENT_CODE 1
50    FOLDER "Core"
51)
52
53target_include_directories(libbacktrace
54    PUBLIC
55        "src"
56    PRIVATE
57        ${LIBBACKTRACE_PRIVATE_INCLUDE_DIRS}
58)
59