-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
82 lines (67 loc) · 1.82 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
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "CMAKE_BUILD_TYPE not set, defaulting to DEBUG")
set(CMAKE_BUILD_TYPE DEBUG)
else()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
endif()
message(STATUS "CMAKE_TOOLCHAIN_FILE: ${CMAKE_TOOLCHAIN_FILE}")
project(template C CXX ASM)
include(cmake/utils.cmake)
add_subdirectory(hal)
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/src/*.h
${CMAKE_CURRENT_SOURCE_DIR}/src/*.hxx
${CMAKE_CURRENT_SOURCE_DIR}/src/*.c
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cxx
${CMAKE_CURRENT_SOURCE_DIR}/src/*.s
)
add_executable(${PROJECT_NAME})
target_include_directories(${PROJECT_NAME}
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/src"
)
target_sources(${PROJECT_NAME}
PRIVATE
${SOURCES}
)
set_target_properties(${PROJECT_NAME}
PROPERTIES
SUFFIX ".elf"
C_STANDARD 11
C_EXTENSIONS ON
CMAKE_C_STANDARD_REQUIRED ON
CXX_STANDARD 17
CXX_EXTENSIONS ON
CMAKE_CXX_STANDARD_REQUIRED ON
)
target_compile_options(${PROJECT_NAME}
PRIVATE
-Wall
-Wextra
-Wpedantic
-Werror
-Wstrict-prototypes
-Wmissing-prototypes
-Wduplicated-cond
-Wduplicated-branches
-Wlogical-op
-Wnull-dereference
-Wshadow
-Wconversion
-Wsign-conversion
)
target_link_libraries(${PROJECT_NAME}
PRIVATE
${PROJECT_NAME}-hal
)
target_link_options(${PROJECT_NAME}
PRIVATE
-Wl,-Map=${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.map,--cref
)
utils_target_set_linker_script(${PROJECT_NAME}
${CMAKE_CURRENT_SOURCE_DIR}/link.ld
)
utils_target_generate_hex(${PROJECT_NAME})
utils_target_generate_bin(${PROJECT_NAME})
utils_target_print_size(${PROJECT_NAME})