summaryrefslogtreecommitdiff
path: root/nrf51_toolchain.cmake
blob: 938f6a6b1f140c548658fb399c56f27c2d887f05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
include(CMakeForceCompiler)

set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION 1)
#set(CMAKE_SYSTEM_PROCESSOR cortex-m0)

find_program(ARM_CC arm-none-eabi-gcc ${TOOLCHAIN_DIR}/bin)
find_program(ARM_CXX arm-none-eabi-g++ ${TOOLCHAIN_DIR}/bin)
find_program(ARM_OBJCOPY arm-none-eabi-objcopy ${TOOLCHAIN_DIR}/bin)
find_program(ARM_SIZE_TOOL arm-none-eabi-size ${TOOLCHAIN_DIR}/bin)
     
CMAKE_FORCE_C_COMPILER(${ARM_CC} GNU)
CMAKE_FORCE_CXX_COMPILER(${ARM_CXX} GNU)

list(APPEND ARM_CFLAGS "-mcpu=cortex-m0")
list(APPEND ARM_CFLAGS "-mthumb")
list(APPEND ARM_CFLAGS "-mabi=aapcs")
list(APPEND ARM_CFLAGS "--std=gnu99")
list(APPEND ARM_CFLAGS "-Wall")
list(APPEND ARM_CFLAGS "-mfloat-abi=soft")

# "/usr/bin/arm-none-eabi-gcc"
# -Xlinker
# -Map=build/phone_remote_nrf51_s110_xxac_BOARD_PCA10028.map
# -mcpu=cortex-m0
# -mthumb
# -mabi=aapcs
# -L/home/trygvis/opt/nrf/7.2/components/toolchain/gcc
# -T/home/trygvis/opt/nrf/7.2/components/toolchain/gcc/gcc_nrf51_s110_xxac.ld
# -o build/phone_remote_nrf51_s110_xxac_BOARD_PCA10028.out
# build/main.o

list(APPEND ARM_LDFLAGS "-L${NRF_SDK}/components/toolchain/gcc")
list(APPEND ARM_LDFLAGS "-T${NRF_SDK}/components/toolchain/gcc/gcc_nrf51_s110_xxac.ld")

#list(APPEND ARM_CFLAGS "-DBLE_STACK_SUPPORT_REQD")
#list(APPEND ARM_CFLAGS "-DSOFTDEVICE_PRESENT")
#list(APPEND ARM_CFLAGS "-DS110")
#list(APPEND ARM_CFLAGS "-DSOFTDEVICE_PRESENT")
#list(APPEND ARM_CFLAGS "-DNRF51")
#list(APPEND ARM_CFLAGS "-DBOARD_PCA10028")
#list(APPEND ARM_CFLAGS "-DNRF51422_QFAC_AB")

set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS}" "${ARM_LDFLAGS}")
string(REGEX REPLACE ";" " " CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS}")
set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS}" CACHE STRING "")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" "${ARM_CFLAGS}")
string(REGEX REPLACE ";" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "")

set(BUILD_SHARED_LIBS OFF)