From a14d0173c88b18c3dc03ebb486572bbce22a1048 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Sun, 19 Jul 2026 13:24:41 +0100 Subject: [PATCH] build: update to support building under a hosted cross-compiler --- CMakeLists.txt | 6 ++---- debug/CMakeLists.txt | 1 + libmagenta/CMakeLists.txt | 16 ++++++++++++++-- tools/e64patch/CMakeLists.txt | 2 ++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cabcb47..fece6bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,6 @@ cmake_minimum_required(VERSION 3.31) project(magenta C ASM) -if (NOT BUILD_TOOLS_DIR) - message(FATAL_ERROR "No build tools directory specified. Please run build.sh") -endif () - set(CMAKE_C_STANDARD 17) set(kernel_arch x86_64) @@ -85,3 +81,5 @@ target_include_directories(magenta_debug PRIVATE libc/include libmagenta/include arch/${kernel_arch}/include) + +install(TARGETS ${kernel_exe_name} DESTINATION boot) diff --git a/debug/CMakeLists.txt b/debug/CMakeLists.txt index 03a2e96..313c821 100644 --- a/debug/CMakeLists.txt +++ b/debug/CMakeLists.txt @@ -2,3 +2,4 @@ file(GLOB sources *.c *.h include/magenta/debug/*.h) add_library(magenta_debug STATIC ${sources}) target_include_directories(magenta_debug PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) +target_compile_options(magenta_debug PRIVATE -ffreestanding -nostdlib) diff --git a/libmagenta/CMakeLists.txt b/libmagenta/CMakeLists.txt index 8d63b4d..f5aa163 100644 --- a/libmagenta/CMakeLists.txt +++ b/libmagenta/CMakeLists.txt @@ -1,4 +1,9 @@ -file(GLOB headers ${CMAKE_CURRENT_SOURCE_DIR}/include/magenta/*.h) +cmake_minimum_required(VERSION 3.31) +project(libmagenta C ASM) + +file(GLOB headers + ${CMAKE_CURRENT_SOURCE_DIR}/include/magenta/*.h + ${CMAKE_CURRENT_SOURCE_DIR}/include-user/magenta/*.h) file(GLOB asm_sources ${CMAKE_CURRENT_SOURCE_DIR}/arch/${CMAKE_SYSTEM_PROCESSOR}/*.S) @@ -6,7 +11,14 @@ set(public_include_dirs ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/include-user) -add_library(libmagenta STATIC ${asm_sources}) +add_library(libmagenta STATIC ${asm_sources} ${headers}) target_include_directories(libmagenta PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/include-user) +target_compile_options(libmagenta PRIVATE -ffreestanding -nostdlib) + +set_target_properties(libmagenta PROPERTIES + PREFIX "") + +install(TARGETS libmagenta) +install(FILES ${headers} DESTINATION include/magenta) diff --git a/tools/e64patch/CMakeLists.txt b/tools/e64patch/CMakeLists.txt index c8776a5..99feda2 100644 --- a/tools/e64patch/CMakeLists.txt +++ b/tools/e64patch/CMakeLists.txt @@ -1,3 +1,5 @@ file(GLOB sources *.c *.h) add_executable(e64patch ${sources}) + +install(TARGETS e64patch)