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(sel4test-driver C)
16
17set(configure_string "")
18
19config_option(Sel4testHaveTimer HAVE_TIMER "Enable tests that require a timer driver" DEFAULT ON)
20
21config_option(
22    Sel4testHaveCache
23    HAVE_CACHE
24    "Enable tests that require a functioning cache"
25    DEFAULT
26    ON
27)
28if(Sel4testAllowSettingsOverride)
29    mark_as_advanced(CLEAR Sel4testHaveTimer Sel4testHaveCache)
30else()
31    mark_as_advanced(FORCE Sel4testHaveTimer Sel4testHaveCache)
32endif()
33add_config_library(sel4test-driver "${configure_string}")
34
35find_package(musllibc REQUIRED)
36find_package(util_libs REQUIRED)
37find_package(seL4_libs REQUIRED)
38find_package(sel4_projects_libs REQUIRED)
39
40# Need to disable GC sections as it causes our tests to be stripped sometimes
41# This option is tested in the following musllibc_setup_build_environment_with_sel4runtime call.
42set(UserLinkerGCSections OFF CACHE BOOL "" FORCE)
43# This sets up environment build flags and imports musllibc and runtime libraries.
44musllibc_setup_build_environment_with_sel4runtime()
45sel4_import_libsel4()
46util_libs_import_libraries()
47sel4_libs_import_libraries()
48
49# Setting LibNanopb On causes its libraries to be created when sel4_projects_libs_import_libraries
50# is called.
51set(LibNanopb ON CACHE BOOL "" FORCE)
52sel4_projects_libs_import_libraries()
53add_subdirectory(../../libsel4testsupport libsel4testsupport)
54
55file(
56    GLOB
57        static
58        src/*.c
59        src/tests/*.c
60        src/arch/${KernelArch}/*.c
61        src/plat/${KernelPlatform}/*.c
62        src/arch/${KernelArch}/*.S
63        src/plat/${KernelPlatform}/*.S
64)
65
66# Import build rules for test app
67add_subdirectory(../sel4test-tests sel4test-tests)
68include(cpio)
69MakeCPIO(archive.o "$<TARGET_FILE:sel4test-tests>")
70
71add_executable(sel4test-driver EXCLUDE_FROM_ALL ${static} archive.o)
72target_include_directories(sel4test-driver PRIVATE "include")
73target_link_libraries(
74    sel4test-driver
75    PUBLIC
76        sel4_autoconf
77        muslc
78        sel4
79        sel4runtime
80        sel4allocman
81        sel4vka
82        sel4utils
83        sel4rpc
84        sel4test
85        sel4platsupport
86        sel4muslcsys
87        sel4testsupport
88    PRIVATE sel4test-driver_Config
89)
90target_compile_options(sel4test-driver PRIVATE -Werror -g)
91
92# Set this image as the rootserver
93include(rootserver)
94DeclareRootserver(sel4test-driver)
95