/
CMakeLists.txt
80 lines (68 loc) · 2.34 KB
/
CMakeLists.txt
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# mbed Microcontroller Library
# Copyright (c) 2014 ARM Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# this custom build file pulls in different startup assembly based on the
# toolchain being used
if(${CMAKE_C_COMPILER_ID} STREQUAL GNU)
set(STARTUP_ASM "bootstrap_gcc/startup_MK64F12.S")
set(STARTUP_SRC "")
elseif(${CMAKE_C_COMPILER_ID} STREQUAL ARMCC)
set(STARTUP_ASM "bootstrap_armcc/startup_MK64F12.s")
set(STARTUP_SRC "")
# unfortunately, for armlink we have to pass the executable startup code as
# an object file, not as part of an archive.
#
add_library(mbed-hal-k64f_startupcod OBJECT ${STARTUP_ASM})
# This is the "neatest" way of making sure the startup code gets linked
# into every executable. Needless to say this is, despite its brevity,
# not neat.
macro (add_executable _name)
_add_executable(${ARGV} $<TARGET_OBJECTS:mbed-hal-k64f_startupcod>)
Endmacro()
else()
set(STARTUP_ASM "")
set(STARTUP_SRC "")
message(FATAL_ERROR "Unsupported target toolchain (gcc and armcc are supported)")
endif()
enable_language(ASM)
set_property(SOURCE ${STARTUP_ASM} PROPERTY LANGUAGE ASM)
add_library(mbed-hal-k64f
${STARTUP_ASM}
${STARTUP_SRC}
"fsl_clock_K64F12.c"
"fsl_sim_hal_K64F12.c"
"crc.c"
)
set_target_properties(mbed-hal-k64f PROPERTIES
LINKER_LANGUAGE C
)
# uvisor-lib is only a dependency if we're building for gcc
if(TARGET_LIKE_GCC)
set(EXTRA_LINK_LIBS uvisor-lib)
else()
set(EXTRA_LINK_LIBS)
endif()
if(TARGET_LIKE_FRDM_K64F)
set(PLATFORM_SPECIFIC_HAL_LIB mbed-hal-frdm-k64f)
elseif(TARGET_LIKE_MTS_GAMBIT)
set(PLATFORM_SPECIFIC_HAL_LIB mbed-hal-gambit)
else()
message(FATAL_ERROR "Missing PLATFORM_SPECIFIC_HAL_LIB")
endif()
target_link_libraries(mbed-hal-k64f
${EXTRA_LINK_LIBS}
mbed-hal
${PLATFORM_SPECIFIC_HAL_LIB}
)