Skip to content
Snippets Groups Projects
Commit 3533ba88 authored by Damiano Amatruda's avatar Damiano Amatruda
Browse files

Merge branch 'cmake-dev' into 'master'

Add support for CMake

See merge request scs/miosix-kernel!2
parents a75e1d15 17d75668
Branches
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
miosix/_doc/doxygen/html/* miosix/_doc/doxygen/html/*
# Exclude temporary files # Exclude temporary files
build/
main.elf main.elf
main.bin main.bin
main.hex main.hex
......
cmake_minimum_required(VERSION 3.16)
project(MiosixProject C CXX ASM)
set(KPATH miosix CACHE PATH "Path to kernel directory")
set(OPT_BOARD "" CACHE STRING "Target board")
if(NOT OPT_BOARD)
message(FATAL_ERROR "No board selected")
endif()
add_subdirectory(${KPATH} EXCLUDE_FROM_ALL)
add_executable(main main.cpp)
target_link_libraries(main miosix::miosix-${OPT_BOARD})
add_custom_command(
TARGET main POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -O ihex main main.hex
COMMAND ${CMAKE_OBJCOPY} -O binary main main.bin
BYPRODUCTS main.hex main.bin
)
# Copyright (c) 2021 Skyward Experimental Rocketry
# Authors: Damiano Amatruda, Michele Scuttari
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
cmake_minimum_required(VERSION 3.16)
project(Miosix C CXX ASM)
set(KPATH ${CMAKE_CURRENT_LIST_DIR} CACHE PATH "Path to kernel directory")
file(GLOB KPATH ${KPATH})
if(NOT KPATH)
message(FATAL_ERROR "Kernel directory not found")
endif()
include(${KPATH}/config/boards.cmake)
foreach(OPT_BOARD ${BOARDS})
set(DFLAGS -MMD -MP)
include(${KPATH}/config/options.cmake)
set(MIOSIX_LIBRARY miosix-${OPT_BOARD})
add_library(${MIOSIX_LIBRARY} STATIC
kernel/kernel.cpp
kernel/sync.cpp
kernel/error.cpp
kernel/pthread.cpp
kernel/stage_2_boot.cpp
kernel/elf_program.cpp
kernel/process.cpp
kernel/process_pool.cpp
kernel/timeconversion.cpp
kernel/SystemMap.cpp
kernel/scheduler/priority/priority_scheduler.cpp
kernel/scheduler/control/control_scheduler.cpp
kernel/scheduler/edf/edf_scheduler.cpp
filesystem/file_access.cpp
filesystem/file.cpp
filesystem/stringpart.cpp
filesystem/console/console_device.cpp
filesystem/mountpointfs/mountpointfs.cpp
filesystem/devfs/devfs.cpp
filesystem/fat32/fat32.cpp
filesystem/fat32/ff.cpp
filesystem/fat32/diskio.cpp
filesystem/fat32/wtoupper.cpp
filesystem/fat32/ccsbcs.cpp
stdlib_integration/libc_integration.cpp
stdlib_integration/libstdcpp_integration.cpp
e20/e20.cpp
e20/unmember.cpp
util/util.cpp
util/unicode.cpp
util/version.cpp
util/crc16.cpp
util/lcd44780.cpp
${ARCH_SRC}
)
add_library(miosix::${MIOSIX_LIBRARY} ALIAS ${MIOSIX_LIBRARY})
target_sources(${MIOSIX_LIBRARY} INTERFACE ${BOOT_FILE})
target_include_directories(${MIOSIX_LIBRARY} PUBLIC
${KPATH}/config
${KPATH}/config/${BOARD_INC}
${KPATH}
${KPATH}/arch/common
${KPATH}/${ARCH_INC}
${KPATH}/${BOARD_INC}
)
target_compile_definitions(${MIOSIX_LIBRARY} PUBLIC COMPILING_MIOSIX)
target_compile_features(${MIOSIX_LIBRARY} PUBLIC cxx_std_14)
target_compile_options(${MIOSIX_LIBRARY} PUBLIC ${DFLAGS} $<$<COMPILE_LANGUAGE:C>:${CFLAGS_BASE}> $<$<COMPILE_LANGUAGE:CXX>:${CXXFLAGS_BASE}> $<$<COMPILE_LANGUAGE:ASM>:${AFLAGS_BASE}>)
set_property(TARGET ${MIOSIX_LIBRARY} PROPERTY INTERFACE_LINK_DEPENDS ${LINKER_SCRIPT})
target_link_options(${MIOSIX_LIBRARY} INTERFACE ${LFLAGS_BASE})
target_link_libraries(${MIOSIX_LIBRARY} INTERFACE stdc++ c m gcc atomic)
add_custom_command(
TARGET ${MIOSIX_LIBRARY} POST_BUILD
COMMAND perl ${KPATH}/_tools/kernel_global_objects.pl $<TARGET_OBJECTS:${MIOSIX_LIBRARY}>
VERBATIM
COMMAND_EXPAND_LISTS
)
endforeach()
# Copyright (c) 2021 Skyward Experimental Rocketry
# Author: Damiano Amatruda
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
# Select compiler
set(PREFIX /opt/arm-miosix-eabi/bin/arm-miosix-eabi-)
# From compiler prefix form the name of the compiler and other tools
set(CMAKE_C_COMPILER_WORKS 1)
set(CMAKE_C_COMPILER ${PREFIX}gcc)
set(CMAKE_CXX_COMPILER_WORKS 1)
set(CMAKE_CXX_COMPILER ${PREFIX}g++)
set(CMAKE_AR ${PREFIX}ar)
set(CMAKE_ASM_COMPILER ${PREFIX}as)
set(CMAKE_OBJCOPY ${PREFIX}objcopy)
set(CMAKE_OBJDUMP ${PREFIX}objdump)
set(SIZE ${PREFIX}size)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
# Copyright (c) 2021 Skyward Experimental Rocketry
# Author: Damiano Amatruda
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
set(BOARDS
lpc2138_miosix_board
stm32f103ze_stm3210e-eval
stm32f103ve_mp3v2
stm32f100rb_stm32vldiscovery
stm32f103ve_strive_mini
stm32f103ze_redbull_v2
stm32f407vg_stm32f4discovery
stm32f207ig_stm3220g-eval
stm32f207zg_ethboard_v2
stm32f207ze_als_camboard
stm32f205rg_sony-newman
stm32l151_als_mainboard
stm32f407vg_bitsboard
stm32f429zi_stm32f4discovery
stm32f103cb_als_mainboard_rev2
stm32f100cb_tempsensor
stm32f429zi_oledboard2
efm32gg332f1024_wandstem
stm32f411re_nucleo
stm32f429zi_skyward_anakin
stm32f100rc_solertegiard
stm32f205rc_skyward_stormtrooper
stm32f401vc_stm32f4discovery
stm32f103c8_breakout
stm32f100c8_microboard
stm32f469ni_stm32f469i-disco
stm32f429zi_skyward_homeone
stm32f429zi_skyward_rogallina
stm32f103c8_skyward_alderaan
stm32f401re_nucleo
stm32f746zg_nucleo
stm32h753xi_eval
stm32f407vg_thermal_test_chip
stm32f205_generic
stm32f103cx_generic
stm32f103cb_skyward_strain_board
stm32f072rb_stm32f0discovery
stm32f429zi_skyward_death_stack
stm32f429zi_skyward_death_stack_x
stm32f100cx_generic
stm32f407vg_skyward_tortellino
stm32f303vc_stm32f3discovery
stm32f100c8_vaisala_rs41
stm32l476rg_nucleo
atsam4lc2aa_generic
)
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment