2023-01-22 14:31:21 -05:00
|
|
|
cmake_minimum_required(VERSION 3.10)
|
2023-11-25 04:57:54 -05:00
|
|
|
project(blink)
|
2023-01-22 14:31:21 -05:00
|
|
|
|
|
|
|
# set(CMAKE_VERBOSE_MAKEFILE ON)
|
2023-11-24 23:38:23 -05:00
|
|
|
set(CMAKE_C_COMPILER riscv-none-elf-gcc)
|
|
|
|
set(CMAKE_CXX_COMPILER riscv-none-elf-gcc)
|
|
|
|
set(CMAKE_OBJCOPY riscv-none-elf-objcopy)
|
|
|
|
set(CMAKE_SIZE riscv-none-elf-size)
|
2023-01-22 14:31:21 -05:00
|
|
|
|
|
|
|
set_property(SOURCE Startup/startup_ch32v00x.S PROPERTY LANGUAGE C)
|
|
|
|
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
|
|
|
|
|
|
|
include_directories(Debug)
|
|
|
|
include_directories(Core)
|
|
|
|
include_directories(User)
|
|
|
|
include_directories(Peripheral/inc)
|
2023-11-24 23:38:23 -05:00
|
|
|
|
2023-11-25 04:49:35 -05:00
|
|
|
add_definitions(-Wall -Wextra -march=rv32ec_zicsr -mabi=ilp32e -msmall-data-limit=0 -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common)
|
2023-01-22 14:31:21 -05:00
|
|
|
|
2024-03-21 22:27:35 -04:00
|
|
|
IF(SDI_PRINTF)
|
|
|
|
add_definitions(-DSDI_PRINT=1)
|
|
|
|
ENDIF(SDI_PRINTF)
|
|
|
|
|
2023-01-22 14:31:21 -05:00
|
|
|
file(GLOB SOURCES "Debug/*.c" "Core/*.c" "User/*.c" "Peripheral/src/*.c" "Startup/*.S")
|
|
|
|
|
|
|
|
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.hex
|
|
|
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
|
|
|
COMMAND ${CMAKE_OBJCOPY}
|
|
|
|
ARGS -O ihex ${CMAKE_PROJECT_NAME}.elf ${CMAKE_PROJECT_NAME}.hex)
|
|
|
|
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.siz
|
|
|
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
|
|
|
COMMAND ${CMAKE_SIZE}
|
|
|
|
ARGS --format=berkeley ${CMAKE_PROJECT_NAME}.elf)
|
|
|
|
|
2023-11-24 23:38:23 -05:00
|
|
|
add_executable(${CMAKE_PROJECT_NAME}.elf ${SOURCES})
|
|
|
|
|
|
|
|
target_link_options(${CMAKE_PROJECT_NAME}.elf PRIVATE -T ${CMAKE_SOURCE_DIR}/Ld/Link.ld -march=rv32ec_zicsr -mabi=ilp32e -nostartfiles -Xlinker -gc-sections --specs=nano.specs --specs=nosys.specs -mcmodel=medany)
|