gcc.cmake 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # Setting Linux is forcing th extension to be .o instead of .obj when building on WIndows.
  2. # It is important because armlink is failing when files have .obj extensions (error with
  3. # scatter file section not found)
  4. SET(CMAKE_SYSTEM_NAME Linux)
  5. SET(CMAKE_SYSTEM_PROCESSOR arm)
  6. #SET(tools "C:/PROGRA~2/GNUTOO~1/82018-~1")
  7. #SET(CMAKE_C_COMPILER "${tools}/bin/arm-none-eabi-gcc.exe")
  8. #SET(CMAKE_CXX_COMPILER "${tools}/bin/arm-none-eabi-g++.exe")
  9. #SET(CMAKE_ASM_COMPILER "${tools}/bin/arm-none-eabi-gcc.exe")
  10. find_program(CMAKE_C_COMPILER NAMES arm-none-eabi-gcc arm-none-eabi-gcc.exe)
  11. find_program(CMAKE_CXX_COMPILER NAMES arm-none-eabi-g++ arm-none-eabi-g++.exe)
  12. find_program(CMAKE_ASM_COMPILER NAMES arm-none-eabi-gcc arm-none-eabi-gcc.exe)
  13. #SET(CMAKE_AR "${tools}/bin/arm-none-eabi-gcc-ar.exe")
  14. find_program(CMAKE_AR NAMES arm-none-eabi-gcc-ar arm-none-eabi-gcc-ar.exe)
  15. find_program(CMAKE_CXX_COMPILER_AR NAMES arm-none-eabi-gcc-ar arm-none-eabi-gcc-ar.exe)
  16. find_program(CMAKE_C_COMPILER_AR NAMES arm-none-eabi-gcc-ar arm-none-eabi-gcc-ar.exe)
  17. #SET(CMAKE_CXX_COMPILER_AR "${tools}/bin/arm-none-eabi-gcc-ar.exe")
  18. #SET(CMAKE_C_COMPILER_AR "${tools}/bin/arm-none-eabi-gcc-ar.exe")
  19. #SET(CMAKE_LINKER "${tools}/bin/arm-none-eabi-g++.exe")
  20. find_program(CMAKE_LINKER NAMES arm-none-eabi-g++ arm-none-eabi-g++.exe)
  21. SET(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <LINK_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
  22. SET(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_LINKER> <LINK_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
  23. SET(CMAKE_C_OUTPUT_EXTENSION .o)
  24. SET(CMAKE_CXX_OUTPUT_EXTENSION .o)
  25. SET(CMAKE_ASM_OUTPUT_EXTENSION .o)
  26. # When library defined as STATIC, this line is needed to describe how the .a file must be
  27. # create. Some changes to the line may be needed.
  28. SET(CMAKE_C_CREATE_STATIC_LIBRARY "<CMAKE_AR> -crs <TARGET> <LINK_FLAGS> <OBJECTS>" )
  29. SET(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_AR> -crs <TARGET> <LINK_FLAGS> <OBJECTS>" )
  30. set(GCC ON)
  31. # default core
  32. if(NOT ARM_CPU)
  33. set(
  34. ARM_CPU "cortex-a5"
  35. CACHE STRING "Set ARM CPU. Default : cortex-a5"
  36. )
  37. endif(NOT ARM_CPU)
  38. SET(CMAKE_C_FLAGS "-g -ffunction-sections -fdata-sections -mcpu=${ARM_CPU}" CACHE INTERNAL "C compiler common flags")
  39. SET(CMAKE_CXX_FLAGS "-g -ffunction-sections -fdata-sections -mcpu=${ARM_CPU}" CACHE INTERNAL "C compiler common flags")
  40. SET(CMAKE_ASM_FLAGS "-mcpu=${ARM_CPU}" CACHE INTERNAL "ASM compiler common flags")
  41. #SET(CMAKE_EXE_LINKER_FLAGS "--specs=nosys.specs" CACHE INTERNAL "linker flags")
  42. get_property(IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
  43. if(IS_IN_TRY_COMPILE)
  44. add_link_options("--specs=nosys.specs")
  45. endif()
  46. add_link_options("-Wl,--start-group")
  47. # Where is the target environment
  48. #SET(CMAKE_FIND_ROOT_PATH "${tools}")
  49. # Search for programs in the build host directories
  50. SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
  51. # For libraries and headers in the target directories
  52. SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
  53. SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)