Advertisement
Guest User

Arduino CMake

a guest
Jul 3rd, 2011
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CMake 2.89 KB | None | 0 0
  1. #Copyright (C) 2011  Devin DeLong
  2. #
  3. #    This program is free software: you can redistribute it and/or modify
  4. #    it under the terms of the GNU General Public License as published by
  5. #    the Free Software Foundation, either version 3 of the License, or
  6. #    (at your option) any later version.
  7. #
  8. #    This program is distributed in the hope that it will be useful,
  9. #    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11. #    GNU General Public License for more details.
  12. #
  13. #    You should have received a copy of the GNU General Public License
  14. #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  15.  
  16.  
  17. # This module defines macros intended for use by cross-compiling toolchain files when
  18. # CMake is not able to automatically detect the compiler identification.
  19. include (CMakeForceCompiler)
  20.  
  21. # Set this for cross compiling.  Otherwise it is set to CMAKE_HOST_SYSTEM_NAME,
  22. # which is the system we are developing on.
  23. set (CMAKE_SYSTEM_NAME Generic)
  24.  
  25. # It sets CMAKE_<lang>_COMPILER to the given compiler and the cmake internal variable
  26. # CMAKE_<lang>_COMPILER_ID to the given compiler-id. It also bypasses the check for
  27. # working compiler and basic compiler information tests.
  28. cmake_force_cxx_compiler (avr-g++ CrossAVR)
  29. cmake_force_c_compiler (avr-gcc CrossAVR)
  30.  
  31. # Appparently we want to use the gnuc99 standard.
  32. set (CSTANDARD "-std=gnu99")
  33.  
  34. # Generate .stabs debugging symbols for assembler source lines. This enables avr-gdb to
  35. # trace through assembler source files.
  36. set (CDEBUG "-gstabs")
  37.  
  38. # Warn for functions declared or defined without specified argument types.
  39. set (CWARN "-Wall -Wstrict-prototypes")
  40.  
  41. # -funsigned-char - Make any unqualfied char type an unsigned char. Without this option,
  42. #   they default to a signed char.
  43. # -funsigned-bitfields - Make any unqualified bitfield type unsigned. By default,
  44. #    they are signed.
  45. # -fpack-struct - Pack all structure members together without holes.
  46. # -fshort-enums - Allocate to an enum type only as many bytes as it needs for the declared
  47. #   range of possible values. Specifically, the enum type will be equivalent to the
  48. #   smallest integer type which has enough room.
  49. set (CTUNING_FLAGS "-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums")
  50.  
  51. # Optimize for size.   The special option -Os is meant to turn on all -O2 optimizations
  52. # that are not expected to increase code size.
  53. set (COPT "-Os")
  54.  
  55. # Finally the compilation flags are now configured.
  56. set(CMAKE_CXX_FLAGS "-mmcu=${ARDUINO_PROCESSOR} -DF_CPU=${ARDUINO_PROCESSOR_FREQ} ${COPT}")
  57. set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} ${CTUNING_FLAGS} ${CWARN} ${CSTANDARD} ${CDEBUG}")
  58.  
  59. # On gentoo, -rdynamic is passed to the compiler. The avr compiler does not recognize this
  60. # option.  Also, we are not building shared libraries.
  61. set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement