-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
99 lines (80 loc) · 2.47 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
cmake_minimum_required(VERSION 3.16)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project(hd44780 C)
option(BUILD_EXAMPLE "Build library example" ON)
################################################################################
# HD44780 library
################################################################################
add_library(hd44780)
add_library(dsabala::hd44780 ALIAS hd44780)
target_sources(hd44780
PRIVATE
src/hd44780.c
PUBLIC
src/hd44780.h
)
target_include_directories(hd44780
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
)
################################################################################
# HD44780 library example
################################################################################
if(BUILD_EXAMPLE)
enable_language(ASM)
add_executable(hd44780-example)
set(CPU_OPTIONS
-mthumb
-mcpu=cortex-m4
-mfpu=fpv4-sp-d16
-mfloat-abi=hard
)
target_compile_options(hd44780
PRIVATE
${CPU_OPTIONS}
)
target_link_libraries(hd44780-example
PRIVATE
hd44780
)
target_compile_options(hd44780-example
PRIVATE
-Og
-Wall
-Wextra
-fdata-sections
-ffunction-sections
-Wno-unused-parameter
${CPU_OPTIONS}
)
target_compile_definitions(hd44780-example
PRIVATE
STM32F407xx
USE_HAL_DRIVER
HSE_VALUE=8000000U
)
target_include_directories(hd44780-example
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/example/src
${CMAKE_CURRENT_SOURCE_DIR}/example/stm32f4-drivers/include
)
target_sources(hd44780-example
PRIVATE
example/src/bsp_lcd.c
example/src/main.c
example/stm32f4-drivers/source/startup_stm32f407xx.s
example/stm32f4-drivers/source/stm32f4xx_hal.c
example/stm32f4-drivers/source/stm32f4xx_hal_cortex.c
example/stm32f4-drivers/source/stm32f4xx_hal_gpio.c
example/stm32f4-drivers/source/system_stm32f4xx.c
)
target_link_options(hd44780-example
PRIVATE
-T${CMAKE_CURRENT_SOURCE_DIR}/example/stm32f4-drivers/STM32F407VGTx_FLASH.ld
-specs=nosys.specs
-lnosys
-lc
-Wl,-Map=${PROJECT_NAME}.map,--gc-sections,--cref,--print-memory-usage
${CPU_OPTIONS}
)
endif()