From aa7a9c99f3c31b56a6af15f5c68aece906c714e2 Mon Sep 17 00:00:00 2001 From: Max Logaev Date: Tue, 23 Dec 2025 21:33:31 +0300 Subject: [PATCH] build: Fixed build dependencies Signed-off-by: Max Logaev --- CMakeLists.txt | 4 ++-- libraries/CMakeLists.txt | 10 ++++++---- tests/CMakeLists.txt | 8 +++++--- tests/hello/CMakeLists.txt | 2 +- toolchain/CMakeLists.txt | 19 ++++++------------- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56894a26fd..19e5eb3f16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ include(ExternalProject) # Number of threads for build set(JOBS 6) -# Installation directory for GCC and Binutils" +# Installation directory for GCC and Binutils if(NOT DEFINED ENV{SDK_TOOLCHAIN_DIR}) message(FATAL_ERROR "The environment variable SDK_TOOLCHAIN_DIR is not set!") endif() @@ -16,7 +16,7 @@ set(SDK_TOOLCHAIN_DIR $ENV{SDK_TOOLCHAIN_DIR}) message(STATUS "SDK_TOOLCHAIN_DIR=${SDK_TOOLCHAIN_DIR}") -# Directory for installing ports" +# Directory for installing ports if(NOT DEFINED ENV{SDK_SYSROOT_DIR}) message(FATAL_ERROR "The environment variable SDK_SYSROOT_DIR is not set!") endif() diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index 81d9775842..fd0b457984 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -1,10 +1,10 @@ # Rules for building libraries # Copy NewLib headers to sysroot dir -add_custom_target(copy-newlib-headers - COMMAND +add_custom_target(newlib-headers + COMMAND ${CMAKE_COMMAND} -E copy_directory - "${CMAKE_CURRENT_SOURCE_DIR}/newlib/libc/include" + "${CMAKE_CURRENT_SOURCE_DIR}/newlib/libc/include" "${SDK_SYSROOT_DIR}/include" COMMENT "Copying all Newlib headers to ${SDK_SYSROOT_DIR}/include" ) @@ -12,9 +12,11 @@ add_custom_target(copy-newlib-headers # Pseudo libc (kos-crt-stub) ExternalProject_Add( kos-crt-stub - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/kos-crt-stub + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/kos-crt-stub CMAKE_ARGS -DCMAKE_C_COMPILER=i586-kolibrios-gcc -DCMAKE_C_COMPILER_WORKS=1 -DCMAKE_INSTALL_PREFIX=${SDK_SYSROOT_DIR} + BUILD_ALWAYS TRUE + DEPENDS gcc ) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b65dcbe0e7..283226fe32 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,12 +1,14 @@ # Rules for building tests -# Pseudo libc (kos-crt-stub) ExternalProject_Add( test-hello - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/hello - CMAKE_ARGS + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/hello + CMAKE_ARGS -DCMAKE_C_COMPILER=i586-kolibrios-gcc -DCMAKE_C_COMPILER_WORKS=1 -DCMAKE_INSTALL_PREFIX=${SDK_SYSROOT_DIR} BUILD_ALWAYS TRUE + DEPENDS + gcc + kos-crt-stub ) diff --git a/tests/hello/CMakeLists.txt b/tests/hello/CMakeLists.txt index 21077c142a..a6c905a96f 100644 --- a/tests/hello/CMakeLists.txt +++ b/tests/hello/CMakeLists.txt @@ -2,4 +2,4 @@ cmake_minimum_required(VERSION 3.31) project(hello) add_executable(hello hello.c) -install(TARGETS hello DESTINATION bin) +install(TARGETS hello DESTINATION tests) diff --git a/toolchain/CMakeLists.txt b/toolchain/CMakeLists.txt index bf9cf0851f..f97535a163 100644 --- a/toolchain/CMakeLists.txt +++ b/toolchain/CMakeLists.txt @@ -36,24 +36,17 @@ ExternalProject_Add( --disable-nls --enable-shared --enable-languages=c - BUILD_COMMAND + BUILD_COMMAND make -j${JOBS} all-gcc all-target-libgcc INSTALL_COMMAND make install-strip-gcc install-target-libgcc - DEPENDS - binutils + DEPENDS binutils ) -add_dependencies(gcc copy-newlib-headers) +add_dependencies(gcc newlib-headers) # Copy kos-app.lds -add_custom_target(copy-kos-app-lds - COMMAND - ${CMAKE_COMMAND} -E copy - "${CMAKE_CURRENT_SOURCE_DIR}/kos-app.lds" - "${SDK_TOOLCHAIN_DIR}/i586-kolibrios/lib/" +file( + COPY "${CMAKE_CURRENT_SOURCE_DIR}/kos-app.lds" + DESTINATION "${SDK_TOOLCHAIN_DIR}/i586-kolibrios/lib/" ) - -# Toolchain -add_custom_target(toolchain) -add_dependencies(toolchain gcc copy-kos-app-lds kos-crt-stub)