-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
76 lines (63 loc) · 2.08 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
cmake_minimum_required(VERSION 3.22)
#
# User is free to modify the file as much as necessary
#
list(APPEND CMAKE_MODULE_PATH "{{sr:cmake_path}}")
include("cmake/gcc-arm-none-eabi.cmake")
message("Build CMAKE_MODULE_PATH: " ${CMAKE_MODULE_PATH})
# Core project settings
project(blinky_bare_metal_asm)
enable_language(ASM)
message("Build type: " ${CMAKE_BUILD_TYPE})
# Sources
set(sources_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/Src/blinky.s
)
# Now call generated cmake
# This will add script generated
# information to the project
include("cmake/vscode_generated.cmake")
# Link directories setup
# Must be before executable is added
link_directories(${CMAKE_PROJECT_NAME} ${link_DIRS})
# Create an executable object type
add_executable(${CMAKE_PROJECT_NAME})
set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY LINKER_LANGUAGE ASM)
# Add sources to executable
target_sources(${CMAKE_PROJECT_NAME} PUBLIC ${sources_SRCS})
# Compiler options
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE
${cpu_PARAMS}
${compiler_OPTS}
-Wall
-Wextra
-Wpedantic
-Wno-unused-parameter
$<$<COMPILE_LANGUAGE:C>: >
$<$<COMPILE_LANGUAGE:CXX>:
# -Wno-volatile
# -Wold-style-cast
# -Wuseless-cast
# -Wsuggest-override
>
$<$<COMPILE_LANGUAGE:ASM>:-x assembler-with-cpp -MMD -MP>
$<$<CONFIG:Debug>:-Og -g3 -ggdb>
$<$<CONFIG:Release>:-Og -g0>
)
# Linker options
target_link_options(${CMAKE_PROJECT_NAME} PRIVATE
-nostdlib
-T${linker_script_SRC}
${cpu_PARAMS}
${linker_OPTS}
-Wl,-Map=${CMAKE_PROJECT_NAME}.map
--specs=nosys.specs
-Wl,-z,max-page-size=8 # Allow good software remapping across address space (with proper GCC section making)
-Wl,--print-memory-usage
)
# Execute post-build to print size, generate hex and bin
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_SIZE} $<TARGET_FILE:${CMAKE_PROJECT_NAME}>
COMMAND ${CMAKE_OBJCOPY} -O ihex $<TARGET_FILE:${CMAKE_PROJECT_NAME}> ${CMAKE_PROJECT_NAME}.hex
COMMAND ${CMAKE_OBJCOPY} -O binary $<TARGET_FILE:${CMAKE_PROJECT_NAME}> ${CMAKE_PROJECT_NAME}.bin
)