aboutsummaryrefslogtreecommitdiff
path: root/kernel/CMakeLists.txt
blob: 854fb33a0caf4c5621873f08fd8180fe81161e26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
add_library("kernel_objs" OBJECT
    # Platform-independent KAPI implementation
    "kapi/boot_modules.cpp"
    "kapi/cio.cpp"
    "kapi/cpu.cpp"
    "kapi/interrupts.cpp"
    "kapi/memory.cpp"
    "kapi/system.cpp"

    # KSTD OS Implementation
    "kstd/os.cpp"
    "kstd/print.cpp"

    # Kernel Implementation
    "src/memory/bitmap_allocator.cpp"
    "src/memory/block_list_allocator.cpp"
    "src/memory.cpp"
    "src/devices/block_device.cpp"
    "src/devices/block_device_utils.cpp"
    "src/devices/storage/controller.cpp"
    "src/devices/storage/management.cpp"
    "src/devices/storage/ram_disk/controller.cpp"
    "src/devices/storage/ram_disk/device.cpp"
    "src/filesystem/devfs/filesystem.cpp"
    "src/filesystem/devfs/inode.cpp"
    "src/filesystem/ext2/filesystem.cpp"
    "src/filesystem/ext2/inode.cpp"
    "src/filesystem/dentry.cpp"
    "src/filesystem/device_inode.cpp"
    "src/filesystem/file_descriptor_table.cpp"
    "src/filesystem/filesystem.cpp"
    "src/filesystem/inode.cpp"
    "src/filesystem/mount_table.cpp"
    "src/filesystem/mount.cpp"
    "src/filesystem/open_file_description.cpp"
    "src/filesystem/rootfs/filesystem.cpp"
    "src/filesystem/rootfs/inode.cpp"
    "src/filesystem/vfs.cpp"
)

target_include_directories("kernel_objs" PUBLIC
    "include"
)

target_link_libraries("kernel_objs" PUBLIC
    "os::kapi"
)

file(GLOB_RECURSE KERNEL_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "include/**.hpp")

target_sources("kernel_objs" PUBLIC
    FILE_SET HEADERS
    BASE_DIRS "include"
    FILES
    ${KERNEL_HEADERS}
)

add_library("os::kernel" ALIAS "kernel_objs")

if(CMAKE_CROSSCOMPILING)
    add_executable("kernel"
        "src/main.cpp"
        "src/memory/operators.cpp"
    )

    target_link_libraries("kernel" PRIVATE
        "os::arch"
        "os::kernel"
    )

    target_link_options("kernel" PRIVATE
        "-T${KERNEL_LINKER_SCRIPT}"
        "-no-pie"
        "-nostdlib"
    )

    set_property(TARGET "kernel"
        APPEND
        PROPERTY LINK_DEPENDS
        "${KERNEL_LINKER_SCRIPT}"
    )

    target_disassemble("kernel")
    target_extract_debug_symbols("kernel")
    target_strip("kernel")

    target_generate_bootable_iso("kernel")
else()
    enable_coverage("kernel_objs")
    add_subdirectory("tests")
endif()