From 80f9481deac5bf6562d2e7a9fdfa9fc47fa55a68 Mon Sep 17 00:00:00 2001 From: Alberto Nidasio Date: Sat, 13 Apr 2024 16:19:06 +0200 Subject: [PATCH] Add checks to ensure that the `board_options.cmake` files defines all the required variables --- miosix/cmake/miosix_add_board_libraries.cmake | 30 +++++++++++++++++-- miosix/cmake/miosix_link_target.cmake | 2 +- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/miosix/cmake/miosix_add_board_libraries.cmake b/miosix/cmake/miosix_add_board_libraries.cmake index fc7dbc75c..7e6306ebb 100644 --- a/miosix/cmake/miosix_add_board_libraries.cmake +++ b/miosix/cmake/miosix_add_board_libraries.cmake @@ -32,16 +32,42 @@ # - Miosix::boot-${BOARD_NAME} # - Miosix::miosix-${BOARD_NAME} function(miosix_add_board_libraries BOARD_OPTIONS_FILE) - # Get board options and kernel sources - # The files are included here to scope all the variables + if(NOT KPATH) + message(FATAL_ERROR "KPATH must be defined to be the path to the miosix-kernel/miosix directory") + endif() + include(${BOARD_OPTIONS_FILE}) include(${KPATH}/cmake/kernel_sources.cmake) + miosix_check_board_options_variables() + miosix_add_interface_library(${BOARD_NAME}) miosix_add_boot_library(${BOARD_NAME}) miosix_add_miosix_library(${BOARD_NAME}) endfunction() +# Aborts if the required variables to generate the libraries are missing +function(miosix_check_board_options_variables) + set(VARIABLES + BOARD_NAME + ARCH_PATH + BOARD_PATH + BOARD_CONFIG_PATH + BOOT_FILE + LINKER_SCRIPT + AFLAGS + LFLAGS + CFLAGS + CXXFLAGS + ARCH_SRC + ) + foreach(VARIABLE ${VARIABLES}) + if(NOT DEFINED ${VARIABLE}) + message(FATAL_ERROR "You must define ${VARIABLE} in your board_options.cmake file") + endif() + endforeach() +endfunction() + # Adds an interface library with all the include directories and compile options needed to compile kernel code function(miosix_add_interface_library BOARD_NAME) set(INTERFACE_LIB interface-${BOARD_NAME}) diff --git a/miosix/cmake/miosix_link_target.cmake b/miosix/cmake/miosix_link_target.cmake index 15f50dd6e..4f355271d 100644 --- a/miosix/cmake/miosix_link_target.cmake +++ b/miosix/cmake/miosix_link_target.cmake @@ -41,7 +41,7 @@ endfunction() # Function to link the Miosix libraries to a target and register the build command function(miosix_link_target TARGET OPT_BOARD) - if(NOT OPT_BOARD) + if(NOT DEFINED OPT_BOARD) message(FATAL_ERROR "No board selected") endif()