-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
81 lines (62 loc) · 2.98 KB
/
Copy pathCMakeLists.txt
File metadata and controls
81 lines (62 loc) · 2.98 KB
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
81
# export our linkerscript
set_property(GLOBAL PROPERTY TARGET_LINKERSCRIPT "${CMAKE_CURRENT_LIST_DIR}/linkerscript.ld")
# set the atsam4s2b cpu options as a seperate target so the driver layer can link agains klib
add_library(target_cpu_options INTERFACE)
set_target_properties(target_cpu_options PROPERTIES FOLDER "klib")
# alias projectname::target_cpu_options to target_cpu_options
add_library(${PROJECT_NAME}::target_cpu_options ALIAS target_cpu_options)
# include the arm directory for all the cmsis files
target_include_directories(target_cpu_options INTERFACE ${CMAKE_CURRENT_LIST_DIR}/../../arm/)
# set the cpu options for the compiler
target_compile_options(target_cpu_options INTERFACE "-march=armv7e-m")
target_compile_options(target_cpu_options INTERFACE "-mcpu=cortex-m4")
target_compile_options(target_cpu_options INTERFACE "-mthumb")
# set the cpu options for the linker
target_link_options(target_cpu_options INTERFACE "-march=armv7e-m")
target_link_options(target_cpu_options INTERFACE "-mcpu=cortex-m4")
target_link_options(target_cpu_options INTERFACE "-mthumb")
# other compiler settings
target_compile_options(target_cpu_options INTERFACE "-Wno-attributes")
target_compile_options(target_cpu_options INTERFACE "-fno-non-call-exceptions")
target_compile_options(target_cpu_options INTERFACE "-fno-common")
target_compile_options(target_cpu_options INTERFACE "-ffunction-sections")
target_compile_options(target_cpu_options INTERFACE "-fdata-sections")
target_compile_options(target_cpu_options INTERFACE "-fno-exceptions")
target_compile_options(target_cpu_options INTERFACE "-fno-asynchronous-unwind-tables")
# cpu atsam4s2b target drivers
set(SOURCES
${CMAKE_CURRENT_LIST_DIR}/../../arm/vector_table/cortex-m4.cpp
)
set(HEADERS_PRIVATE
)
set(HEADERS_PUBLIC
)
# add the target_cpu library
add_library(target_cpu OBJECT
${SOURCES}
${HEADERS_PUBLIC}
${HEADERS_PRIVATE}
)
set_target_properties(target_cpu PROPERTIES FOLDER "klib")
# alias projectname::target_cpu to target_cpu
add_library(${PROJECT_NAME}::target_cpu ALIAS target_cpu)
# enable C++20 support for the library
target_compile_features(target_cpu PUBLIC cxx_std_20)
# set the target_cpu for klib
get_filename_component(TARGET_CPU_FOLDER ${CMAKE_CURRENT_LIST_DIR} NAME)
set_property(GLOBAL PROPERTY TARGET_CPU ${TARGET_CPU_FOLDER})
target_compile_definitions(target_cpu PUBLIC "TARGET_CPU=${TARGET_CPU}")
# add target specific compile options
target_compile_options(target_cpu PUBLIC $<$<COMPILE_LANGUAGE:CXX>:-Wno-volatile>)
# link to klib and target_cpu_options
target_link_libraries(target_cpu PUBLIC target_cpu_options)
target_link_libraries(target_cpu PUBLIC klib)
# Global includes. Used by all targets
# Note:
# - header can be included by C++ code `#include <target/target.hpp>`
# - header location in project: ${CMAKE_CURRENT_BINARY_DIR}/generated_headers
target_include_directories(
target_cpu PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>"
"$<BUILD_INTERFACE:${GENERATED_HEADERS_DIR}>"
)