1#
2# Copyright 2019, Data61, CSIRO (ABN 41 687 119 230)
3#
4# SPDX-License-Identifier: BSD-2-Clause
5#
6
7cmake_minimum_required(VERSION 3.7.2)
8
9set(project_dir "${CMAKE_CURRENT_LIST_DIR}/../../")
10file(GLOB project_modules ${project_dir}/projects/*)
11list(
12    APPEND
13        CMAKE_MODULE_PATH
14        ${project_dir}/kernel
15        ${project_dir}/tools/seL4/cmake-tool/helpers/
16        ${project_dir}/tools/seL4/elfloader-tool/
17        ${project_modules}
18)
19
20set(PICOTCP_PATH "${project_dir}/projects/picotcp" CACHE INTERNAL "")
21set(BBL_PATH ${project_dir}/tools/riscv-pk CACHE STRING "BBL Folder location")
22set(COGENT_PATH ${project_dir}/tools/cogent/cogent CACHE INTERNAL "")
23set(RUMPRUN_PATH ${project_dir}/tools/rumprun CACHE INTERNAL "")
24
25set(SEL4_CONFIG_DEFAULT_ADVANCED ON)
26
27include(application_settings)
28include(${CMAKE_CURRENT_LIST_DIR}/easy-settings.cmake)
29
30# figure out the valid apps
31set(app_names "")
32file(GLOB apps ${CMAKE_CURRENT_LIST_DIR}/apps/*)
33foreach(ARG ${apps})
34    get_filename_component(filename ${ARG} NAME)
35    list(APPEND app_names "${filename}")
36endforeach()
37string(
38    REPLACE
39        ";"
40        "\n  "
41        app_names_error
42        "${app_names}"
43)
44
45if("${CAMKES_APP}" STREQUAL "")
46    message(
47        FATAL_ERROR "Missing option -DCAMKES_APP=<app> to build. Valid apps:\n  ${app_names_error}"
48    )
49endif()
50
51list(FIND app_names "${CAMKES_APP}" app_exists)
52if(${app_exists} EQUAL -1)
53    message(
54        FATAL_ERROR
55            "Invalid value for option -DCAMKES_APP=${CAMKES_APP}. Valid options:\n  ${app_names_error}"
56    )
57endif()
58
59if(ARM_HYP)
60    set(KernelArmHypervisorSupport ON CACHE BOOL "" FORCE)
61endif()
62
63correct_platform_strings()
64
65find_package(seL4 REQUIRED)
66sel4_configure_platform_settings()
67
68set(valid_platforms ${KernelPlatform_all_strings} ${correct_platform_strings_platform_aliases})
69set_property(CACHE PLATFORM PROPERTY STRINGS ${valid_platforms})
70if(NOT "${PLATFORM}" IN_LIST valid_platforms)
71    message(FATAL_ERROR "Invalid PLATFORM selected: \"${PLATFORM}\"
72Valid platforms are: \"${valid_platforms}\"")
73endif()
74
75if(SIMULATION)
76    ApplyCommonSimulationSettings(${KernelArch})
77endif()
78
79ApplyCommonReleaseVerificationSettings(${RELEASE} FALSE)
80
81# If an application specific settings file exists then import it here.
82# This can be used for applications to configure the kernel in specific ways
83include(${CMAKE_CURRENT_LIST_DIR}/apps/${CAMKES_APP}/settings.cmake OPTIONAL)
84