Skip to content

Commit

Permalink
More CMake flag fixes (#60)
Browse files Browse the repository at this point in the history
amends #59 

- cmake defaults to empty variables. if repo is some place else, git
simply errors out and the resulting description var will also be empty
(like it is currently happening in actions .yml)
- toolchain .cmake is 'sourced' multiple times when running cmake for
the first time. Instead of using list var, just use the built-in global flag
setter (which also takes care of flag unique-ness, as well as caching)
- -std=... flags were missing
- files with platform-specific things are suffixed with *-esp8266.cmake
  • Loading branch information
mcspr authored Jul 13, 2022
1 parent 03dcc3e commit 06164fb
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
ESP8266_ARDUINO_CORE_DIR: ${{ github.workspace }}/esp8266
run: |
cmake \
--toolchain=${{ github.workspace }}/repo/cmake/toolchain.cmake \
--toolchain=${{ github.workspace }}/repo/cmake/toolchain-esp8266.cmake \
-DCMAKE_PROGRAM_PATH=${ESP8266_ARDUINO_CORE_DIR}/tools/xtensa-lx106-elf/bin \
-DESP8266_ARDUINO_CORE_DIR=${ESP8266_ARDUINO_CORE_DIR} \
-S repo \
Expand Down
33 changes: 16 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
cmake_minimum_required(VERSION 3.11)
project(lwip-glue-builder
VERSION 20220704
VERSION 20220711
DESCRIPTION "lwip-glue-builder"
LANGUAGES C
)

list(APPEND compile_options
"-nostdlib"
"-ffunction-sections"
"-fdata-sections"
"-falign-functions=4")
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 11)

list(APPEND compile_options
"-Wall"
"-Wextra"
"-Wpointer-arith"
"-Werror=return-type")
add_compile_options(
-nostdlib
-ffunction-sections
-fdata-sections
-falign-functions=4)

list(APPEND compile_options
"-Os"
"-g")
add_compile_options(
-Wall
-Wextra
-Wpointer-arith
-Werror=return-type)

add_compile_options("${compile_options}")

message(STATUS "default options: " "${compile_options}")
add_compile_options(
-Os
-g)

set(UPSTREAM_VERSION "STABLE-2_1_3_RELEASE")
set(LWIP_TAG ${UPSTREAM_VERSION})
Expand Down
4 changes: 2 additions & 2 deletions README-CMake.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
To build & install everything into the specific ESP8266 Core directory:
```
$ cmake \
--toolchain=cmake/toolchain.cmake \
-DCMAKE_PROGRAM_PATH=<path to the toolchain bin directory> \
--toolchain=cmake/toolchain-esp8266.cmake \
-DCMAKE_PROGRAM_PATH=<path to the gcc toolchain bin directory> \
-DESP8266_ARDUINO_CORE_DIR=<path to the arduino core directory> \
-B build
$ cmake --build build
Expand Down
2 changes: 1 addition & 1 deletion cmake/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

execute_process(
COMMAND git describe --tag
WORKING_DIRECTORY "${GLUE_DIR}"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE GLUE_REPO_DESC_STR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions cmake/toolchain.cmake → cmake/toolchain-esp8266.cmake
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
include(Compiler/GNU)

set(CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_CURRENT_LIST_DIR}/esp8266-platform.cmake")
set(CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_CURRENT_LIST_DIR}/platform-esp8266.cmake")
set(CMAKE_SYSTEM_NAME "Generic")

set(triple xtensa-lx106-elf)

set(CMAKE_C_COMPILER ${triple}-gcc)
set(CMAKE_CXX_COMPILER ${triple}-g++)

list(APPEND compile_options
"-mlongcalls"
"-mtext-section-literals")
add_compile_options(
-mlongcalls
-mtext-section-literals)

set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")

Expand Down

0 comments on commit 06164fb

Please sign in to comment.