-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathCMakeLists.txt
90 lines (75 loc) · 2.63 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
cmake_minimum_required(VERSION 3.11)
project(lwip-glue-builder
VERSION 20220711
DESCRIPTION "lwip-glue-builder"
LANGUAGES C
)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 11)
add_compile_options(
-nostdlib
-ffunction-sections
-fdata-sections
-falign-functions=4)
add_compile_options(
-Wall
-Wextra
-Wpointer-arith
-Werror=return-type)
add_compile_options(
-Os
-g)
set(UPSTREAM_VERSION "STABLE-2_1_3_RELEASE")
set(LWIP_TAG ${UPSTREAM_VERSION})
# TODO: never assume this is in-tree of esp8266/Arduino, force to give some path
set(ESP8266_ARDUINO_CORE_DIR "" CACHE FILEPATH "Arduino Core default path")
if (NOT EXISTS ${ESP8266_ARDUINO_CORE_DIR})
message(SEND_ERROR ${ESP8266_ARDUINO_CORE_DIR})
message(FATAL_ERROR "Core directory does not exist")
endif()
message(STATUS "core dir: " "${ESP8266_ARDUINO_CORE_DIR}")
# fetches lwip2-src into the current build directory, then automatically patches it
file(GLOB LWIP_PATCHES ${CMAKE_SOURCE_DIR}/patches/*.patch)
message(STATUS "patches: " "${LWIP_PATCHES}")
# TODO: GIT_CONFIG needed for windows install. lwip.git repo classifies .h as text through .gitattributes, and git-clone will apply native eol conversion
# by default, git does not attribute .h files as text, so when installing .h into the esp8266 repo it will make them differ when all that's different is eol
include(FetchContent)
FetchContent_Declare(
lwip2
GIT_REPOSITORY https://git.savannah.nongnu.org/git/lwip.git
GIT_TAG ${LWIP_TAG}
GIT_CONFIG core.autocrlf=false core.eol=lf
PATCH_COMMAND git reset --hard && git clean -f && git apply --3way --recount --whitespace=fix ${LWIP_PATCHES}
)
FetchContent_MakeAvailable(lwip2)
FetchContent_GetProperties(lwip2 SOURCE_DIR)
set(LWIP_DIR ${lwip2_SOURCE_DIR})
message(STATUS "lwip dir: " "${LWIP_DIR}")
message(STATUS "lwip tag: " "${LWIP_TAG}")
# the actual builder consists of a glue_variant(NAME DEFINITIONS), which will add a library target to build the actual sources
# from the glue, glue-esp and the lwip2-src
include(cmake/lwip-builder.cmake)
glue_variant(
NAME lwip2-1460
DEFINITIONS -DTCP_MSS=1460 -DLWIP_FEATURES=0 -DLWIP_IPV6=0
)
glue_variant(
NAME lwip2-1460-feat
DEFINITIONS -DTCP_MSS=1460 -DLWIP_FEATURES=1 -DLWIP_IPV6=0
)
glue_variant(
NAME lwip2-536
DEFINITIONS -DTCP_MSS=536 -DLWIP_FEATURES=0 -DLWIP_IPV6=0
)
glue_variant(
NAME lwip2-536-feat
DEFINITIONS -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0
)
glue_variant(
NAME lwip6-536
DEFINITIONS -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=1
)
glue_variant(
NAME lwip6-1460
DEFINITIONS -DTCP_MSS=1460 -DLWIP_FEATURES=1 -DLWIP_IPV6=1
)