Christophe Favergeon | 6b604eb | 2019-05-17 13:46:33 +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 | |
Christophe Favergeon | 3b2a0ee | 2019-06-12 13:29:14 +0200 | [diff] [blame] | 9 | #SET(tools "C:/PROGRA~1/ARM/DEVELO~1.0/sw/ARMCOM~1.12") |
Christophe Favergeon | 6b604eb | 2019-05-17 13:46:33 +0200 | [diff] [blame] | 10 | |
Christophe Favergeon | 3b2a0ee | 2019-06-12 13:29:14 +0200 | [diff] [blame] | 11 | find_program(CMAKE_C_COMPILER NAMES armclang armclang.exe) |
| 12 | find_program(CMAKE_CXX_COMPILER NAMES armclang armclang.exe) |
| 13 | find_program(CMAKE_ASM_COMPILER NAMES armclang armclang.exe) |
Christophe Favergeon | 6b604eb | 2019-05-17 13:46:33 +0200 | [diff] [blame] | 14 | |
Christophe Favergeon | 3b2a0ee | 2019-06-12 13:29:14 +0200 | [diff] [blame] | 15 | #SET(CMAKE_C_COMPILER "${tools}/bin/armclang.exe") |
| 16 | #SET(CMAKE_CXX_COMPILER "${tools}/bin/armclang.exe") |
| 17 | #SET(CMAKE_ASM_COMPILER "${tools}/bin/armclang.exe") |
| 18 | |
| 19 | find_program(CMAKE_AR NAMES armar armar.exe) |
| 20 | |
| 21 | #SET(CMAKE_AR "${tools}/bin/armar.exe") |
| 22 | find_program(CMAKE_CXX_COMPILER_AR NAMES armar armar.exe) |
| 23 | find_program(CMAKE_C_COMPILER_AR NAMES armar armar.exe) |
| 24 | |
| 25 | find_program(CMAKE_LINKER NAMES armlink armlink.exe) |
| 26 | #SET(CMAKE_LINKER "${tools}/bin/armlink.exe") |
| 27 | |
Christophe Favergeon | 6b604eb | 2019-05-17 13:46:33 +0200 | [diff] [blame] | 28 | SET(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <LINK_FLAGS> -o <TARGET> <LINK_LIBRARIES> <OBJECTS>") |
Christophe Favergeon | 3b2a0ee | 2019-06-12 13:29:14 +0200 | [diff] [blame] | 29 | SET(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_LINKER> <LINK_FLAGS> -o <TARGET> <LINK_LIBRARIES> <OBJECTS>") |
| 30 | |
| 31 | SET(CMAKE_C_RESPONSE_FILE_LINK_FLAG "--via ") |
Christophe Favergeon | 6b604eb | 2019-05-17 13:46:33 +0200 | [diff] [blame] | 32 | SET(CMAKE_C_OUTPUT_EXTENSION .o) |
| 33 | SET(CMAKE_CXX_OUTPUT_EXTENSION .o) |
| 34 | SET(CMAKE_ASM_OUTPUT_EXTENSION .o) |
| 35 | # When library defined as STATIC, this line is needed to describe how the .a file must be |
| 36 | # create. Some changes to the line may be needed. |
Christophe Favergeon | 3b2a0ee | 2019-06-12 13:29:14 +0200 | [diff] [blame] | 37 | SET(CMAKE_C_CREATE_STATIC_LIBRARY "<CMAKE_AR> -r -s --create <TARGET> <LINK_FLAGS> <OBJECTS>" ) |
| 38 | SET(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_AR> -r -s --create <TARGET> <LINK_FLAGS> <OBJECTS>" ) |
| 39 | |
| 40 | #SET(CMAKE_ASM_CREATE_STATIC_LIBRARY "${tools}/bin/armar.exe -r -s --create <TARGET> <LINK_FLAGS> <OBJECTS>" ) |
| 41 | |
| 42 | |
Christophe Favergeon | 6b604eb | 2019-05-17 13:46:33 +0200 | [diff] [blame] | 43 | set(ARMAC6 ON) |
| 44 | # default core |
| 45 | |
| 46 | if(NOT ARM_CPU) |
| 47 | set( |
| 48 | ARM_CPU "cortex-a5" |
| 49 | CACHE STRING "Set ARM CPU. Default : cortex-a5" |
| 50 | ) |
| 51 | endif(NOT ARM_CPU) |
| 52 | |
Christophe Favergeon | c67252c | 2020-06-18 11:11:51 +0200 | [diff] [blame] | 53 | if (AARCH64) |
| 54 | SET(CMAKE_C_FLAGS "-mcpu=${ARM_CPU} --target=aarch64-arm-none-eabi" CACHE INTERNAL "C compiler common flags") |
| 55 | SET(CMAKE_CXX_FLAGS "-mcpu=${ARM_CPU} --target=aarch64-arm-none-eabi" CACHE INTERNAL "C compiler common flags") |
| 56 | SET(CMAKE_ASM_FLAGS "-g -x assembler-with-cpp -masm=auto -mcpu=${ARM_CPU} --target=aarch64-arm-none-eabi" CACHE INTERNAL "ASM compiler common flags") |
| 57 | else() |
Christophe Favergeon | 6b604eb | 2019-05-17 13:46:33 +0200 | [diff] [blame] | 58 | SET(CMAKE_C_FLAGS "-mcpu=${ARM_CPU} --target=arm-arm-none-eabi" CACHE INTERNAL "C compiler common flags") |
| 59 | SET(CMAKE_CXX_FLAGS "-mcpu=${ARM_CPU} --target=arm-arm-none-eabi" CACHE INTERNAL "C compiler common flags") |
| 60 | SET(CMAKE_ASM_FLAGS "-g -x assembler-with-cpp -masm=auto -mcpu=${ARM_CPU} --target=arm-arm-none-eabi" CACHE INTERNAL "ASM compiler common flags") |
Christophe Favergeon | c67252c | 2020-06-18 11:11:51 +0200 | [diff] [blame] | 61 | endif() |
Christophe Favergeon | 3b2a0ee | 2019-06-12 13:29:14 +0200 | [diff] [blame] | 62 | #SET(CMAKE_ASM_FLAGS "--cpu=${ARM_CPU}" CACHE INTERNAL "ASM compiler common flags") |
Christophe Favergeon | 6b604eb | 2019-05-17 13:46:33 +0200 | [diff] [blame] | 63 | #SET(CMAKE_EXE_LINKER_FLAGS "-flto" CACHE INTERNAL "linker flags") |
| 64 | |
| 65 | # Where is the target environment |
Christophe Favergeon | 3b2a0ee | 2019-06-12 13:29:14 +0200 | [diff] [blame] | 66 | #SET(CMAKE_FIND_ROOT_PATH "${tools}") |
Christophe Favergeon | 6b604eb | 2019-05-17 13:46:33 +0200 | [diff] [blame] | 67 | # Search for programs in the build host directories |
| 68 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) |
| 69 | # For libraries and headers in the target directories |
| 70 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) |
| 71 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) |
| 72 | |
Christophe Favergeon | 3b2a0ee | 2019-06-12 13:29:14 +0200 | [diff] [blame] | 73 | #include(CMakePrintHelpers) |
| 74 | #cmake_print_variables(${ASM_DIALECT}) |