Luna/kernel/CMakeLists.txt

160 lines
4.4 KiB
CMake
Raw Normal View History

2022-12-04 11:47:08 +00:00
# The Moon kernel for Luna.
file(GLOB_RECURSE HEADERS src/*.h)
2022-11-13 09:09:09 +00:00
set(SOURCES
${HEADERS}
2022-11-13 09:09:09 +00:00
src/main.cpp
2022-11-30 12:29:28 +00:00
src/Log.cpp
2023-08-12 19:38:25 +00:00
src/Pledge.cpp
src/cxxabi.cpp
src/Symbols.cpp
2022-11-19 16:59:39 +00:00
src/video/Framebuffer.cpp
2022-11-20 16:55:22 +00:00
src/video/TextConsole.cpp
2022-11-19 16:59:39 +00:00
src/memory/MemoryManager.cpp
src/memory/Heap.cpp
src/memory/KernelVM.cpp
src/memory/AddressSpace.cpp
src/memory/MemoryMap.cpp
2023-08-02 20:18:36 +00:00
src/memory/SharedMemory.cpp
2022-11-19 16:59:39 +00:00
src/boot/Init.cpp
2022-11-13 09:30:10 +00:00
src/arch/Serial.cpp
src/arch/PCI.cpp
2023-09-20 05:05:33 +00:00
src/lib/Mutex.cpp
2022-12-07 14:03:34 +00:00
src/thread/Thread.cpp
src/thread/ThreadImage.cpp
2022-12-07 14:03:34 +00:00
src/thread/Scheduler.cpp
src/thread/Clock.cpp
src/sys/Syscall.cpp
src/sys/exit.cpp
2023-01-06 23:21:08 +00:00
src/sys/clock_gettime.cpp
src/sys/mmap.cpp
src/sys/usleep.cpp
src/sys/open.cpp
src/sys/exec.cpp
2023-03-11 17:02:50 +00:00
src/sys/file.cpp
2023-03-11 21:19:58 +00:00
src/sys/id.cpp
2023-03-12 14:32:09 +00:00
src/sys/mkdir.cpp
src/sys/pstat.cpp
2023-03-23 21:42:24 +00:00
src/sys/waitpid.cpp
2023-03-28 19:28:56 +00:00
src/sys/getdents.cpp
2023-04-10 17:56:03 +00:00
src/sys/stat.cpp
2023-04-11 20:15:21 +00:00
src/sys/chdir.cpp
src/sys/link.cpp
2023-04-24 18:34:44 +00:00
src/sys/uname.cpp
src/sys/mount.cpp
src/sys/resource.cpp
2023-07-10 17:46:57 +00:00
src/sys/signal.cpp
src/sys/socket.cpp
2023-08-02 12:48:20 +00:00
src/sys/poll.cpp
2023-11-16 20:48:18 +00:00
src/sys/setitimer.cpp
2023-08-12 19:38:25 +00:00
src/sys/pledge.cpp
src/sys/memstat.cpp
src/fs/VFS.cpp
src/fs/Pipe.cpp
src/fs/Mount.cpp
src/fs/MBR.cpp
src/fs/GPT.cpp
src/fs/StorageCache.cpp
src/fs/OpenFileDescription.cpp
src/fs/FSRegistry.cpp
src/net/UnixSocket.cpp
src/fs/tmpfs/FileSystem.cpp
src/fs/tmpfs/Inode.cpp
src/fs/devpts/FileSystem.cpp
src/fs/devpts/Inode.cpp
src/fs/ext2/FileSystem.cpp
src/fs/ext2/Inode.cpp
src/fs/devices/DeviceRegistry.cpp
src/fs/devices/BlockDevice.cpp
src/fs/devices/NullDevice.cpp
2023-03-30 19:19:16 +00:00
src/fs/devices/ZeroDevice.cpp
2023-05-27 08:42:45 +00:00
src/fs/devices/FullDevice.cpp
src/fs/devices/ConsoleDevice.cpp
src/fs/devices/FramebufferDevice.cpp
src/fs/devices/UARTDevice.cpp
2023-08-02 09:55:45 +00:00
src/fs/devices/MouseDevice.cpp
src/fs/devices/KeyboardDevice.cpp
src/fs/devices/PTYMultiplexer.cpp
src/fs/devices/MasterPTY.cpp
src/fs/devices/SlavePTY.cpp
2023-10-14 17:00:10 +00:00
src/fs/devices/TTYLink.cpp
src/fs/InitRD.cpp
src/binfmt/ELF.cpp
src/binfmt/BinaryFormat.cpp
src/binfmt/Script.cpp
2022-11-13 09:30:10 +00:00
)
if("${LUNA_ARCH}" MATCHES "x86_64")
2022-11-19 17:00:45 +00:00
set(SOURCES
${SOURCES}
src/arch/x86_64/IO.cpp
src/arch/x86_64/Serial.cpp
src/arch/x86_64/MMU.cpp
src/arch/x86_64/CPU.cpp
src/arch/x86_64/Clock.cpp
2022-12-07 14:03:34 +00:00
src/arch/x86_64/Thread.cpp
src/arch/x86_64/PCI.cpp
2023-03-19 10:17:43 +00:00
src/arch/x86_64/Keyboard.cpp
src/arch/x86_64/disk/ATA.cpp
src/arch/x86_64/init/GDT.cpp
src/arch/x86_64/init/IDT.cpp
src/arch/x86_64/init/PIC.cpp
2023-08-02 09:55:45 +00:00
src/arch/x86_64/PS2Mouse.cpp
2022-11-19 17:00:45 +00:00
)
endif()
2022-11-13 09:09:09 +00:00
2022-11-15 18:10:32 +00:00
add_executable(moon ${SOURCES})
2022-11-13 09:09:09 +00:00
if("${LUNA_ARCH}" MATCHES "x86_64")
2022-11-19 16:59:39 +00:00
set(ASM_SOURCES
src/arch/x86_64/CPU.asm
src/arch/x86_64/Entry.asm
2022-11-19 16:59:39 +00:00
)
add_library(moon-asm STATIC ${ASM_SOURCES})
target_link_libraries(moon moon-asm)
endif()
target_link_libraries(moon luna-freestanding)
2022-11-13 09:09:09 +00:00
target_compile_definitions(moon PRIVATE IN_MOON)
target_compile_options(moon PRIVATE ${COMMON_FLAGS})
target_compile_options(moon PRIVATE -nostdlib -mcmodel=kernel -ffreestanding -fno-threadsafe-statics)
2022-11-15 18:10:32 +00:00
if("${LUNA_ARCH}" MATCHES "x86_64")
2022-11-19 16:59:39 +00:00
target_compile_options(moon PRIVATE -mno-red-zone)
target_compile_options(moon PRIVATE -mno-80387 -mno-mmx -mno-sse -mno-sse2)
target_link_options(moon PRIVATE -mno-red-zone)
endif()
2022-11-15 18:10:32 +00:00
if(MOON_DEBUG)
include(debug.cmake)
2022-12-04 09:27:25 +00:00
endif()
if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/config.cmake)
message(STATUS "Using custom config.cmake file")
include(config.cmake)
endif()
if(BUILD_TESTS)
target_compile_definitions(moon PRIVATE MOON_ENABLE_TESTING_FEATURES)
endif()
2022-11-15 18:10:32 +00:00
target_link_options(moon PRIVATE -lgcc -Wl,--build-id=none -z max-page-size=0x1000 -mcmodel=kernel)
2022-11-13 10:25:15 +00:00
set_target_properties(moon PROPERTIES CXX_STANDARD 20)
2022-11-13 09:30:10 +00:00
target_include_directories(moon PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src)
2023-01-06 23:21:08 +00:00
target_include_directories(moon PRIVATE ${LUNA_BASE}/usr/include)
2022-11-13 09:09:09 +00:00
2022-12-03 16:25:25 +00:00
configure_file(src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/gen/config.h @ONLY)
target_include_directories(moon PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/gen)
2022-11-13 09:09:09 +00:00
target_link_options(moon PRIVATE LINKER:-T ${CMAKE_CURRENT_LIST_DIR}/moon.ld -nostdlib -nodefaultlibs)
add_custom_command(TARGET moon POST_BUILD COMMAND ${LUNA_ROOT}/tools/generate-symbols.sh)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/moon" DESTINATION ${LUNA_ROOT}/initrd/boot)