1#
2# Copyright 2017, Data61
3# Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4# ABN 41 687 119 230.
5#
6# This software may be distributed and modified according to the terms of
7# the BSD 2-Clause license. Note that NO WARRANTY is provided.
8# See "LICENSE_BSD2.txt" for details.
9#
10# @TAG(DATA61_BSD)
11#
12
13cmake_minimum_required(VERSION 3.7.2)
14
15project(libsel4vka C)
16
17set(configure_string "")
18
19config_option(LibVKAAllowMemoryLeaks LIB_VKA_ALLOW_MEMORY_LEAKS "Leak memory on free \
20    Changes the default free functions to silently leak memory \
21    instead of assert failing. \
22    This is useful in scenarios where code is correctly freeing \
23    resources, but you want to use an allocator that does not \
24    implement free." DEFAULT OFF)
25
26config_string(
27    LibVKADebugLiveSlotsSZ
28    LIB_SEL4_VKA_DEBUG_LIVE_SLOTS_SZ
29    "(debug allocator) live slot buffer size \
30    VKA contains an allocator, debugvka, that wraps a target VKA allocator \
31    for the purposes of debugging. It tracks slot and object allocations \
32    and catches both caller problems like double free, and allocator \
33    problems like handing out the same resource twice. This configuration \
34    option sets the maximum number of CSlots that can be tracked at any one \
35    time."
36    DEFAULT
37    0
38    UNQUOTE
39)
40
41config_string(
42    LibVKADebugLiveObjsSZ
43    LIB_SEL4_VKA_DEBUG_LIVE_OBJS_SZ
44    "(debug allocator) live object buffer size \
45    As for the above option, but sets the maximum number of objects that \
46    can be tracked at any one time."
47    DEFAULT
48    0
49    UNQUOTE
50)
51mark_as_advanced(LibVKAAllowMemoryLeaks LibVKADebugLiveSlotsSZ LibVKADebugLiveObjsSZ)
52add_config_library(sel4vka "${configure_string}")
53
54file(GLOB deps src/*.c)
55
56list(SORT deps)
57
58add_library(sel4vka STATIC EXCLUDE_FROM_ALL ${deps})
59target_include_directories(
60    sel4vka
61    PUBLIC include "sel4_arch_include/${KernelSel4Arch}" "arch_include/${KernelArch}"
62)
63target_link_libraries(
64    sel4vka
65    PUBLIC
66        muslc
67        sel4
68        utils
69        sel4vka_Config
70        sel4_autoconf
71)
72if(KernelDebugBuild)
73    target_link_libraries(sel4vka PUBLIC sel4debug)
74endif()
75