You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
2.6 KiB
50 lines
2.6 KiB
# the name of the target operating system
|
|
set (CMAKE_SYSTEM_NAME Generic)
|
|
set(CMAKE_SYSTEM_PROCESSOR arm)
|
|
|
|
set(CROSS_COMPILE arm-none-eabi-)
|
|
|
|
# which compilers to use for C and C++
|
|
set(CMAKE_C_COMPILER ${CROSS_COMPILE}gcc${CMAKE_EXECUTABLE_SUFFIX})
|
|
set(CMAKE_CXX_COMPILER ${CROSS_COMPILE}g++${CMAKE_EXECUTABLE_SUFFIX})
|
|
set(CMAKE_ASM_COMPILER ${CROSS_COMPILE}gcc${CMAKE_EXECUTABLE_SUFFIX})
|
|
set(CMAKE_AR ${CROSS_COMPILE}ar${CMAKE_EXECUTABLE_SUFFIX})
|
|
set(CMAKE_LINKER ${CROSS_COMPILE}ld${CMAKE_EXECUTABLE_SUFFIX})
|
|
set(CMAKE_OBJCOPY ${CROSS_COMPILE}objcopy${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "")
|
|
set(CMAKE_RANLIB ${CROSS_COMPILE}ranlib${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "")
|
|
set(CMAKE_SIZE ${CROSS_COMPILE}size${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "")
|
|
set(CMAKE_STRIP ${CROSS_COMPILE}strip${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "")
|
|
if (CMAKE_HOST_WIN32)
|
|
set(CMAKE_GDB ${CROSS_COMPILE}gdb${CMAKE_EXECUTABLE_SUFFIX})
|
|
else()
|
|
set(CMAKE_GDB gdb-multiarch)
|
|
endif()
|
|
|
|
# Avoids running the linker during try_compile()
|
|
# Without that flag CMake is not able to pass test compilation check
|
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
|
|
|
set(CORTEX_M4_ARCH_FLAGS "-mthumb -mfloat-abi=hard -mcpu=cortex-m4 -march=armv7e-m -mfpu=fpv4-sp-d16")
|
|
set(CMAKE_C_FLAGS_INIT "${CORTEX_M4_ARCH_FLAGS} -fno-common -Wall -ffunction-sections -fdata-sections -ffreestanding -Wno-unused-function -fno-strict-aliasing -Wshadow -mword-relocations" CACHE INTERNAL "")
|
|
set(CMAKE_CXX_FLAGS_INIT "${CMAKE_C_FLAGS_INIT} -fno-exceptions" CACHE INTERNAL "")
|
|
set(CMAKE_ASM_FLAGS_INIT "${CORTEX_M4_ARCH_FLAGS} -ffunction-sections -fdata-sections -D__ASSEMBLER__ -mword-relocations" CACHE INTERNAL "")
|
|
|
|
set(CMAKE_C_FLAGS_DEBUG "-g -ggdb" CACHE INTERNAL "")
|
|
set(CMAKE_C_FLAGS_RELEASE "-Os -DNDEBUG" CACHE INTERNAL "")
|
|
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG} CACHE INTERNAL "")
|
|
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE} CACHE INTERNAL "")
|
|
# adjust the default behaviour of the FIND_XXX() commands:
|
|
# search headers and libraries in the target environment, search
|
|
# programs in the host environment
|
|
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_EXECUTABLE_SUFFIX_C .elf)
|
|
set(CMAKE_EXECUTABLE_SUFFIX_CXX .elf)
|
|
set(CMAKE_EXECUTABLE_SUFFIX_ASM .elf)
|
|
|
|
function(tgt_add_linker_script TARGET VISIBILITY SCRIPT)
|
|
get_filename_component(SCRIPT "${SCRIPT}" ABSOLUTE)
|
|
target_link_options(${TARGET} ${VISIBILITY} -T "${SCRIPT}")
|
|
endfunction()
|
|
|