Skip to content

Commit

Permalink
Add checks to ensure that the board_options.cmake files defines all…
Browse files Browse the repository at this point in the history
… the required variables
  • Loading branch information
NidasioAlberto committed Apr 13, 2024
1 parent 837d3e2 commit 80f9481
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
30 changes: 28 additions & 2 deletions miosix/cmake/miosix_add_board_libraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion miosix/cmake/miosix_link_target.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 80f9481

Please sign in to comment.