forked from grygorek/FreeRTOS_cpp11
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
147 lines (126 loc) · 5.16 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# @file
#
# @author: Piotr Grygorczuk [email protected]
#
# @copyright Copyright 2019 Piotr Grygorczuk
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# o Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# o Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# o My name may not be used to endorse or promote products derived from this
# software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
cmake_minimum_required(VERSION 3.0)
# ARM Cortex-M4F settings
###########################
if(k64frdmevk)
message(STATUS "Building: K64FRDM EVK board")
set(TARGET_BOARD "k64FRDMevk" CACHE INTERNAL "" FORCE)
set(TARGET_CPU "mk64f12")
set(CPU_ARCH "ARM_CM4F")
set(CPU_VENDOR "NXP")
#SET(CONFIG_DEFS "-DCPU_MK64FN1M0VDC12 -DCPU_MK64FN1M0VLL12 -D__USE_CMSIS -DARMCM4_FP -DENET_ENHANCEDBUFFERDESCRIPTOR_MODE")
SET(CPU_FLAGS "-mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16")
else(k64frdmevk)
message(FATAL_ERROR "Error: Target not specified")
endif(k64frdmevk)
# GCC ARM compiler settings
##############################
set(COMPILER_NAME "GCC")
if(WIN32)
set(COMPILER_PATH "") # add to system path
SET(COMPILER_POSTFIX ".exe")
endif(WIN32)
if(LINUX)
SET(COMPILER_PATH "")
SET(COMPILER_POSTFIX "")
endif(LINUX)
SET(COMPILER_PREFIX arm-none-eabi)
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
SET(CMAKE_C_COMPILER_WORKS TRUE)
SET(CMAKE_CXX_COMPILER_WORKS TRUE)
SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_SYSTEM_VERSION TRUE)
SET(CMAKE_CROSSCOMPILING TRUE)
SET(CMAKE_USE_RELATIVE_PATHS TRUE)
#SET(CMAKE_C_COMPILER ${COMPILER_PATH}/bin/${COMPILER_PREFIX}-gcc${COMPILER_POSTFIX})
#SET(CMAKE_CXX_COMPILER ${COMPILER_PATH}/bin/${COMPILER_PREFIX}-g++${COMPILER_POSTFIX})
#SET(CMAKE_ASM_COMPILER ${COMPILER_PATH}/bin/${COMPILER_PREFIX}-g++${COMPILER_POSTFIX})
SET(CMAKE_C_COMPILER ${COMPILER_PREFIX}-gcc${COMPILER_POSTFIX})
SET(CMAKE_CXX_COMPILER ${COMPILER_PREFIX}-g++${COMPILER_POSTFIX})
SET(CMAKE_ASM_COMPILER ${COMPILER_PREFIX}-g++${COMPILER_POSTFIX})
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_LEGACY_CYGWIN_WIN32 0)
# GCC 7.2.1 includes needed. Or set env path
#INCLUDE_DIRECTORIES(
# ${COMPILER_PATH}/${COMPILER_PREFIX}/include
# ${COMPILER_PATH}/${COMPILER_PREFIX}/include/c++/7.2.1
# ${COMPILER_PATH}/${COMPILER_PREFIX}/include/c++/7.2.1/arm-none-eabi
# ${COMPILER_PATH}/${COMPILER_PREFIX}/include/c++/7.2.1/backward
# ${COMPILER_PATH}/lib/gcc/arm-none-eabi/7.2.1/include
# ${COMPILER_PATH}/lib/gcc/arm-none-eabi/7.2.1/include-fixed
# include
#)
# Enable C++11 multithreading with FreeRTOS
add_compile_definitions(_GCC_MULTITHREAD_FREERTOS_ENABLE)
file(GLOB LINKER_SCRIPTS "${CMAKE_SOURCE_DIR}/*.ld")
file(COPY ${LINKER_SCRIPTS} DESTINATION ${CMAKE_BINARY_DIR})
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--wrap=malloc -Wl,--wrap=free")
set(LINKER_SCRIPT "Linker.ld")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -T ${LINKER_SCRIPT}")
###################
# Project settings
###################
project(rtos C CXX ASM)
# Build Settings
#------------------------
SET(COMPILE_PART_FLAGS "${CPU_FLAGS} -Os")
if(DEBUG)
SET(COMPILE_PART_FLAGS "${CPU_FLAGS} -g3")
endif(DEBUG)
SET(COMPILE_COMMON_FLAGS "${CONFIG_DEFS} ${COMPILE_PART_FLAGS} -Wall -Wextra -Wpedantic -fno-common -fmessage-length=0 -ffunction-sections -fdata-sections")
SET(CMAKE_C_FLAGS "${COMPILE_COMMON_FLAGS} -std=c11 -nostdlib -ffreestanding -fno-builtin " CACHE INTERNAL "" FORCE)
SET(CMAKE_CXX_FLAGS "${COMPILE_COMMON_FLAGS} -std=c++1z -nostdlib -ffreestanding -fno-builtin -fno-exceptions -fno-rtti -fno-unwind-tables" CACHE INTERNAL "" FORCE)
SET(CMAKE_ASM_FLAGS "-x assembler-with-cpp ${COMPILE_PART_FLAGS}" CACHE INTERNAL "" FORCE)
# FreeRTOS library
#----------------------------
include_directories(
FreeRTOS/Source/include
FreeRTOS
FreeRTOS/Source/portable/${COMPILER_NAME}/${CPU_ARCH}
FreeRTOS/cpp11_gcc
)
add_subdirectory(FreeRTOS)
#-----------------------------
add_executable(testapp.elf
main.cpp
sys.cpp
FreeRTOS_hooks.cpp
FreeRTOS_memory.cpp
startup_mk64f12.cpp
)
target_link_libraries(
testapp.elf
freeRTOS
)