Skip to content

Commit

Permalink
Improved CMake code documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
NidasioAlberto committed Jun 18, 2024
1 parent a203064 commit a2f18a9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,20 @@ cmake_minimum_required(VERSION 3.16)

project(Main C CXX ASM)

# Set here your board of choice
set(MIOSIX_OPT_BOARD NOT_SET CACHE STRING "Target board")

add_subdirectory(miosix EXCLUDE_FROM_ALL)

include(LinkTarget)

# List here your source files (.s, .c and .cpp)
add_executable(main main.cpp)

# List here additional include directories
# target_include_directories(main PRIVATE here_your_includes)

# List here additional static libraries
# target_link_libraries(main PRIVATE here_your_libraries)

miosix_link_target(main)
10 changes: 6 additions & 4 deletions miosix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ set(KERNEL_SRC
include(${KPATH}/arch/CMakeLists.txt)

# Verify that all the required variables have been defined, otherwise abort
set(VARIABLES
set(REQUIRED_VARIABLES
MIOSIX_OPT_BOARD
ARCH_INC
BOARD_INC
Expand All @@ -98,7 +98,7 @@ set(VARIABLES
LFLAGS_BASE
ARCH_SRC
)
foreach(VARIABLE ${VARIABLES})
foreach(VARIABLE ${REQUIRED_VARIABLES})
if(NOT DEFINED ${VARIABLE})
message(FATAL_ERROR "Board support package must define ${VARIABLE}")
endif()
Expand All @@ -109,6 +109,7 @@ set(MIOSIX_SETTINGS_PATH ${KPATH}/default CACHE PATH "Include directory for mios

# Define the miosix library with kernel and architecture sources
add_library(miosix STATIC ${KERNEL_SRC} ${ARCH_SRC})

target_include_directories(miosix PUBLIC
${KPATH}
${KPATH}/arch/common
Expand All @@ -118,14 +119,13 @@ target_include_directories(miosix PUBLIC
${MIOSIX_SETTINGS_PATH}
)

# Configure compiler flags
target_compile_options(miosix PUBLIC
$<$<COMPILE_LANGUAGE:ASM>:${AFLAGS_BASE}>
$<$<COMPILE_LANGUAGE:C>:${CFLAGS_BASE}>
$<$<COMPILE_LANGUAGE:CXX>:${CXXFLAGS_BASE}>
)

# Configure program command
# Configure program command as a propery of the miosix library
set_property(TARGET miosix PROPERTY PROGRAM_CMDLINE ${PROGRAM_CMDLINE})

# Add COMPILING_MIOSIX define for private headers
Expand All @@ -135,13 +135,15 @@ target_compile_definitions(miosix PRIVATE $<$<COMPILE_LANGUAGE:C,CXX>:COMPILING_
set_property(TARGET miosix PROPERTY LINK_DEPENDS ${MIOSIX_LINKER_SCRIPT})
target_link_options(miosix PUBLIC ${LFLAGS_BASE})

# Run the kernel_global_objects.pl script on all kernel objects
add_custom_command(
TARGET miosix PRE_LINK
COMMAND perl ${KPATH}/_tools/kernel_global_objects.pl $<TARGET_OBJECTS:miosix>
VERBATIM
COMMAND_EXPAND_LISTS
)

# Optionally print the board list
option(MIOSIX_PRINT_BOARD_LIST "Prints a list of the available boards" OFF)
if(MIOSIX_PRINT_BOARD_LIST)
message(STATUS "Available boards:")
Expand Down

0 comments on commit a2f18a9

Please sign in to comment.