Christophe Favergeon | 3b2a0ee | 2019-06-12 13:29:14 +0200 | [diff] [blame] | 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 | |
| 7 | |
| 8 | |
| 9 | #SET(tools "C:/PROGRA~2/GNUTOO~1/82018-~1") |
| 10 | |
| 11 | #SET(CMAKE_C_COMPILER "${tools}/bin/arm-none-eabi-gcc.exe") |
| 12 | #SET(CMAKE_CXX_COMPILER "${tools}/bin/arm-none-eabi-g++.exe") |
| 13 | #SET(CMAKE_ASM_COMPILER "${tools}/bin/arm-none-eabi-gcc.exe") |
| 14 | |
| 15 | find_program(CMAKE_C_COMPILER NAMES arm-none-eabi-gcc arm-none-eabi-gcc.exe) |
| 16 | find_program(CMAKE_CXX_COMPILER NAMES arm-none-eabi-g++ arm-none-eabi-g++.exe) |
| 17 | find_program(CMAKE_ASM_COMPILER NAMES arm-none-eabi-gcc arm-none-eabi-gcc.exe) |
| 18 | |
| 19 | #SET(CMAKE_AR "${tools}/bin/arm-none-eabi-gcc-ar.exe") |
| 20 | find_program(CMAKE_AR NAMES arm-none-eabi-gcc-ar arm-none-eabi-gcc-ar.exe) |
| 21 | find_program(CMAKE_CXX_COMPILER_AR NAMES arm-none-eabi-gcc-ar arm-none-eabi-gcc-ar.exe) |
| 22 | find_program(CMAKE_C_COMPILER_AR NAMES arm-none-eabi-gcc-ar arm-none-eabi-gcc-ar.exe) |
| 23 | |
| 24 | |
| 25 | #SET(CMAKE_CXX_COMPILER_AR "${tools}/bin/arm-none-eabi-gcc-ar.exe") |
| 26 | #SET(CMAKE_C_COMPILER_AR "${tools}/bin/arm-none-eabi-gcc-ar.exe") |
| 27 | |
| 28 | #SET(CMAKE_LINKER "${tools}/bin/arm-none-eabi-g++.exe") |
| 29 | find_program(CMAKE_LINKER NAMES arm-none-eabi-g++ arm-none-eabi-g++.exe) |
| 30 | |
| 31 | SET(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <LINK_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>") |
| 32 | SET(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_LINKER> <LINK_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>") |
| 33 | SET(CMAKE_C_OUTPUT_EXTENSION .o) |
| 34 | SET(CMAKE_CXX_OUTPUT_EXTENSION .o) |
| 35 | SET(CMAKE_ASM_OUTPUT_EXTENSION .o) |
| 36 | # When library defined as STATIC, this line is needed to describe how the .a file must be |
| 37 | # create. Some changes to the line may be needed. |
Christophe Favergeon | 512b148 | 2020-02-07 11:25:11 +0100 | [diff] [blame] | 38 | SET(CMAKE_C_CREATE_STATIC_LIBRARY "<CMAKE_AR> -crs <TARGET> <LINK_FLAGS> <OBJECTS>" ) |
| 39 | SET(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_AR> -crs <TARGET> <LINK_FLAGS> <OBJECTS>" ) |
Christophe Favergeon | 3b2a0ee | 2019-06-12 13:29:14 +0200 | [diff] [blame] | 40 | |
| 41 | set(GCC ON) |
| 42 | # default core |
| 43 | |
| 44 | if(NOT ARM_CPU) |
| 45 | set( |
| 46 | ARM_CPU "cortex-a5" |
| 47 | CACHE STRING "Set ARM CPU. Default : cortex-a5" |
| 48 | ) |
| 49 | endif(NOT ARM_CPU) |
| 50 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 51 | SET(CMAKE_C_FLAGS "-ffunction-sections -fdata-sections -mcpu=${ARM_CPU}" CACHE INTERNAL "C compiler common flags") |
| 52 | SET(CMAKE_CXX_FLAGS "-ffunction-sections -fdata-sections -mcpu=${ARM_CPU}" CACHE INTERNAL "C compiler common flags") |
Christophe Favergeon | 3b2a0ee | 2019-06-12 13:29:14 +0200 | [diff] [blame] | 53 | SET(CMAKE_ASM_FLAGS "-mcpu=${ARM_CPU}" CACHE INTERNAL "ASM compiler common flags") |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 54 | SET(CMAKE_EXE_LINKER_FLAGS "-mcpu=${ARM_CPU}" CACHE INTERNAL "linker flags") |
Christophe Favergeon | 3b2a0ee | 2019-06-12 13:29:14 +0200 | [diff] [blame] | 55 | |
| 56 | get_property(IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE) |
| 57 | if(IS_IN_TRY_COMPILE) |
| 58 | add_link_options("--specs=nosys.specs") |
| 59 | endif() |
| 60 | |
Christophe Favergeon | c4c3480 | 2019-09-24 14:05:01 +0200 | [diff] [blame] | 61 | add_link_options("-Wl,--start-group") |
Christophe Favergeon | 4eadae9 | 2020-05-29 11:44:53 +0200 | [diff] [blame] | 62 | #add_link_options("-mcpu=${ARM_CPU}") |
Christophe Favergeon | c4c3480 | 2019-09-24 14:05:01 +0200 | [diff] [blame] | 63 | |
Christophe Favergeon | 3b2a0ee | 2019-06-12 13:29:14 +0200 | [diff] [blame] | 64 | # Where is the target environment |
| 65 | #SET(CMAKE_FIND_ROOT_PATH "${tools}") |
| 66 | # Search for programs in the build host directories |
| 67 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) |
| 68 | # For libraries and headers in the target directories |
| 69 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) |
| 70 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) |
| 71 | |