mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
CMake
This commit is contained in:
9
source/CMake/arm-gcc.cmake
Normal file
9
source/CMake/arm-gcc.cmake
Normal file
@@ -0,0 +1,9 @@
|
||||
# which compilers to use for C and C++
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
|
||||
set(CMAKE_C_COMPILER arm-none-eabi-gcc CACHE INTERNAL "C Compiler")
|
||||
set(CMAKE_CXX_COMPILER arm-none-eabi-g++ CACHE INTERNAL "C++ Compiler")
|
||||
set(CMAKE_ASM_COMPILER arm-none-eabi-gcc -x assembler-with-cpp CACHE INTERNAL "ASM Compiler")
|
||||
set(CMAKE_OBJCOPY arm-none-eabi-objcopy CACHE INTERNAL "Object Copy")
|
||||
set(CMAKE_OBJDUMP arm-none-eabi-objdump CACHE INTERNAL "Object Dump")
|
||||
|
||||
|
||||
7
source/CMake/gd32vf1.cmake
Normal file
7
source/CMake/gd32vf1.cmake
Normal file
@@ -0,0 +1,7 @@
|
||||
# core flags
|
||||
|
||||
set(CORE_FLAGS "-march=rv32imac -mabi=ilp32 -mcmodel=medlow -fno-builtin -nostartfiles" CACHE INTERNAL "CPU flags")
|
||||
add_definitions(${CORE_FLAGS})
|
||||
# link with linker file
|
||||
target_link_libraries(${elf_file} PUBLIC -T ${CMAKE_CURRENT_SOURCE_DIR}/linkers/gd32vf103.ld)
|
||||
# target_link_libraries(${elf_file} PUBLIC -nostartfiles --specs=${CMAKE_CURRENT_SOURCE_DIR}/patch.specs)
|
||||
9
source/CMake/riscv-gcc.cmake
Normal file
9
source/CMake/riscv-gcc.cmake
Normal file
@@ -0,0 +1,9 @@
|
||||
# which compilers to use for C and C++
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
|
||||
set(CMAKE_C_COMPILER riscv-none-elf-gcc CACHE INTERNAL "C Compiler")
|
||||
set(CMAKE_CXX_COMPILER riscv-none-elf-g++ CACHE INTERNAL "C++ Compiler")
|
||||
set(CMAKE_ASM_COMPILER riscv-none-elf-gcc -x assembler-with-cpp CACHE INTERNAL "ASM Compiler")
|
||||
set(CMAKE_OBJCOPY riscv-none-elf-objcopy CACHE INTERNAL "Object Copy")
|
||||
set(CMAKE_OBJDUMP riscv-none-elf-objdump CACHE INTERNAL "Object Dump")
|
||||
|
||||
|
||||
26
source/CMake/shared-compiler-settings.cmake
Normal file
26
source/CMake/shared-compiler-settings.cmake
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
# set additional for compiler and linker: optimization and generate map file
|
||||
set(additional_linker_flags -Wl,-Map=${map_file},--cref,--no-warn-mismatch)
|
||||
target_link_libraries(${elf_file} PRIVATE ${additional_linker_flags})
|
||||
|
||||
# remove unused sections
|
||||
target_link_libraries(${elf_file} PUBLIC "-Wl,--gc-sections -Wl,--wrap=malloc -Wl,--wrap=free -Wl,--undefined=vTaskSwitchContext -Wl,--undefined=pxCurrentTCB --specs=nosys.specs -Wl,--print-memory-usage -flto")
|
||||
|
||||
set(TARGET_FLAGS "-DMODEL_${MODEL}")
|
||||
|
||||
set(OPTIM_FLAGS "-Os -flto -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections -fshort-enums -fsingle-precision-constant -ffreestanding -fno-common")
|
||||
|
||||
message(ERROR "flags >${CORE_FLAGS}<")
|
||||
# compiler: language specific flags
|
||||
set(CMAKE_C_FLAGS " ${CORE_FLAGS} ${OPTIM_FLAGS} ${TARGET_FLAGS} -fno-builtin -Wall -std=gnu11 -fdata-sections -ffunction-sections -g3 " CACHE INTERNAL "c compiler flags")
|
||||
set(CMAKE_CXX_FLAGS " ${CORE_FLAGS} ${OPTIM_FLAGS} ${TARGET_FLAGS} -fno-rtti -fno-exceptions -fno-builtin -Wall -std=gnu++11 -fdata-sections -ffunction-sections -g -ggdb3" CACHE INTERNAL "cxx compiler flags")
|
||||
set(CMAKE_ASM_FLAGS " ${CORE_FLAGS} ${OPTIM_FLAGS} ${TARGET_FLAGS} -g -ggdb3 -D__USES_CXX" CACHE INTERNAL "asm compiler flags")
|
||||
|
||||
# search for programs in the build host directories
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
|
||||
# for libraries and headers in the target directories
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
6
source/CMake/stm32f1.cmake
Normal file
6
source/CMake/stm32f1.cmake
Normal file
@@ -0,0 +1,6 @@
|
||||
# core flags
|
||||
|
||||
set(CORE_FLAGS "-mthumb -mcpu=cortex-m3 -mlittle-endian -mfloat-abi=soft" CACHE INTERNAL "CPU flags")
|
||||
add_definitions(${CORE_FLAGS})
|
||||
# link with linker file
|
||||
target_link_libraries(${elf_file} PUBLIC -T ${CMAKE_CURRENT_SOURCE_DIR}/linkers/stm32f103.ld)
|
||||
Reference in New Issue
Block a user