blob: 3f7b6e667bff46f1e37c5923b59cf1d12afed9e5 [file] [log] [blame]
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +02001# 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)
4SET(CMAKE_SYSTEM_NAME Linux)
5SET(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
15find_program(CMAKE_C_COMPILER NAMES arm-none-eabi-gcc arm-none-eabi-gcc.exe)
16find_program(CMAKE_CXX_COMPILER NAMES arm-none-eabi-g++ arm-none-eabi-g++.exe)
17find_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")
20find_program(CMAKE_AR NAMES arm-none-eabi-gcc-ar arm-none-eabi-gcc-ar.exe)
21find_program(CMAKE_CXX_COMPILER_AR NAMES arm-none-eabi-gcc-ar arm-none-eabi-gcc-ar.exe)
22find_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")
29find_program(CMAKE_LINKER NAMES arm-none-eabi-g++ arm-none-eabi-g++.exe)
30
31SET(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <LINK_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
32SET(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_LINKER> <LINK_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
33SET(CMAKE_C_OUTPUT_EXTENSION .o)
34SET(CMAKE_CXX_OUTPUT_EXTENSION .o)
35SET(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 Favergeon512b1482020-02-07 11:25:11 +010038SET(CMAKE_C_CREATE_STATIC_LIBRARY "<CMAKE_AR> -crs <TARGET> <LINK_FLAGS> <OBJECTS>" )
39SET(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_AR> -crs <TARGET> <LINK_FLAGS> <OBJECTS>" )
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020040
41set(GCC ON)
42# default core
43
44if(NOT ARM_CPU)
45 set(
46 ARM_CPU "cortex-a5"
47 CACHE STRING "Set ARM CPU. Default : cortex-a5"
48 )
49endif(NOT ARM_CPU)
50
Christophe Favergeonfeb73932020-05-20 14:48:06 +020051SET(CMAKE_C_FLAGS "-ffunction-sections -fdata-sections -mcpu=${ARM_CPU}" CACHE INTERNAL "C compiler common flags")
52SET(CMAKE_CXX_FLAGS "-ffunction-sections -fdata-sections -mcpu=${ARM_CPU}" CACHE INTERNAL "C compiler common flags")
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020053SET(CMAKE_ASM_FLAGS "-mcpu=${ARM_CPU}" CACHE INTERNAL "ASM compiler common flags")
Christophe Favergeonfeb73932020-05-20 14:48:06 +020054SET(CMAKE_EXE_LINKER_FLAGS "-mcpu=${ARM_CPU}" CACHE INTERNAL "linker flags")
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020055
56get_property(IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
57if(IS_IN_TRY_COMPILE)
58 add_link_options("--specs=nosys.specs")
59endif()
60
Christophe Favergeonc4c34802019-09-24 14:05:01 +020061add_link_options("-Wl,--start-group")
Christophe Favergeon4eadae92020-05-29 11:44:53 +020062#add_link_options("-mcpu=${ARM_CPU}")
Christophe Favergeonc4c34802019-09-24 14:05:01 +020063
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020064# Where is the target environment
65#SET(CMAKE_FIND_ROOT_PATH "${tools}")
66# Search for programs in the build host directories
67SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
68# For libraries and headers in the target directories
69SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
70SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
71