GithubHelp home page GithubHelp logo

awm / arm-cmake-toolchains Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vpetrigo/arm-cmake-toolchains

0.0 0.0 0.0 336 KB

CMake toolchain configurations for ARM

License: BSD 3-Clause "New" or "Revised" License

CMake 75.67% Shell 24.33%

arm-cmake-toolchains's Introduction

Build Status GitHub

CMake toolchain files for ARM GCC compiler

This repo contains CMake toolchain files that utilizes ARM GCC.

One of them arm-gcc-toolchain.cmake uses arm-none-eabi-gcc suite to build CMake project. To use it the toolchain must be added to the system PATH variable.

Example for Ninja generator, Debug build:

PATH=<path/to/arm-none-eabi>:$PATH cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=arm-gcc-toolchain.cmake -DCMAKE_BUILD_TYPE=Debug

clang-arm-gcc-toolchain.cmake uses Clang front-end as a compiler that has some additional code analyzer features with comprehensive warning/errormessages.

Example projects

Customization of toolchain file

Now the arm-gcc-toolchain.cmake and clang-arm-gcc-toolchain.cmake files use arm-none-eabi compiler triple and prefix. In case you want to use another compiler you should change the TOOLCHAIN_PREFIX variable in both CMake toolchain files and TOOLCHAIN_TRIPLE for Clang-specific file only:

# arm-gcc-toolchain.cmake and clang-arm-gcc-toolchain.cmake
set(TOOLCHAIN_PREFIX <your-compiler-prefix>)
# clang-arm-gcc-toolchain.cmake ONLY
set(TOOLCHAIN_TRIPLE <your-compiler-triple>)

Also some options which is essential for Cortex-M specific compiler (arm-none-eabi) might be not relevant for your compiler. In that case you should simply delete obsolete lines from toolchain CMake file. For example the line below is not relevant for uClinux compiler:

set(CMAKE_EXE_LINKER_FLAGS_INIT "--specs=nosys.specs")

And that line can be deleted while you use arm-uclinuxeabi compiler without any side effect.

Additional macros/functions in utils.cmake

In the utils.cmake file you can find some useful macros/functions that you can add into your CMake files. To do that you need to include utils.cmake:

# CMakeLists.txt somewhere in your project
include(<path-to-utils-file>/utils.cmake)

It might be a good idea to include that file in your project's root CMakeLists.txt to allow other CMake files, which may reside in subdirectories, to use provided features.

  • subdirlist:
# store all subfolder names in a ${result} variable
# might be useful when you have lots of subdirectories with
# headers and do not want to type them manually
# IMPORTANT: ${result} contains paths relative to a ${current_dir}
subdirlist(result current_dir)

target_include_directories(<target> ${result})
  • prepend_cur_dir:
# prepend ${CMAKE_CURRENT_SOURCE_DIR} to a directory
# so that you have the full path to a header/source file
# and store the result in the provided ${variable}
prepend_cur_dir(full_path_to_dir dir)
# the ${full_path_to_dir} for dir/ might be like:
${full_path_to_dir} -> C:/Users/SpecificUser/Project/dir
  • firmware_size:
# function that adds custom target that will
# output resulted executable image size by using 
# binutils size command
add_executable(hello_world main.c)
...
firmware_size(hello_world)
# Possible output:
# text    data    bss     dec     hex     filename
# 294880  81920   11592   388392  5ed28   hello_world
  • generate_object:
# function that adds custom target that will
# generate additional output file with specified
# type by using binutils objcopy
add_executable(hello_world main.c)
...
generate_object(hello_world .hex ihex)
# in addition to .elf file the hex file for
# hello_world firmware would be generated

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.