-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
73 lines (59 loc) · 1.73 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
cmake_minimum_required(VERSION 3.17.0)
project(gd32-cmake-example)
enable_language(C CXX ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(USE_LTO "Enable LTO" ON)
if(USE_LTO)
include(CheckIPOSupported)
check_ipo_supported(RESULT supported OUTPUT error)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if (isMultiConfig)
set(CMAKE_CROSS_CONFIGS "Release;Debug")
set(CMAKE_DEFAULT_BUILD_TYPE "Release")
set(CMAKE_DEFAULT_CONFIGS "Release;Debug")
endif ()
option (FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." TRUE)
if (${FORCE_COLORED_OUTPUT})
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options (-fdiagnostics-color=always)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options (-fcolor-diagnostics)
endif ()
endif ()
add_definitions(
-DGD32F450
-DGD32F450I_EVAL
)
add_compile_options(
-mcpu=cortex-m4
-mfloat-abi=hard
-specs=nosys.specs
-ffunction-sections
-fdata-sections
-fstack-usage
-ffast-math
"$<$<CONFIG:Debug>:-Og;-DDEBUG;-g;-funwind-tables>"
"$<$<CONFIG:Release>:-O2;-DNDEBUG>"
"$<$<CONFIG:MinSizeRel>:-Os;-DNDEBUG>"
"$<$<CONFIG:RelWithDebInfo>:-O2;-g;-DNDEBUG>"
)
add_link_options(
-mcpu=cortex-m4
-mfloat-abi=hard
-specs=nosys.specs
-static
-u _printf_float
-Wl,--start-group -lc -lm -lstdc++ -lsupc++ -Wl,--end-group
-Wl,--gc-sections
-T${PROJECT_SOURCE_DIR}/gd32f450.ld
)
set(CMAKE_EXECUTABLE_SUFFIX .elf)
add_subdirectory(Examples)