From 06164fbd55770b0dbb4f52a092f4b924e84f9b8a Mon Sep 17 00:00:00 2001 From: Max Prokhorov Date: Wed, 13 Jul 2022 07:03:01 +0300 Subject: [PATCH] More CMake flag fixes (#60) 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 --- .github/workflows/run.yml | 2 +- CMakeLists.txt | 33 +++++++++---------- README-CMake.md | 4 +-- cmake/common.cmake | 2 +- ...-platform.cmake => platform-esp8266.cmake} | 0 ...oolchain.cmake => toolchain-esp8266.cmake} | 8 ++--- 6 files changed, 24 insertions(+), 25 deletions(-) rename cmake/{esp8266-platform.cmake => platform-esp8266.cmake} (100%) rename cmake/{toolchain.cmake => toolchain-esp8266.cmake} (70%) diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index ca1bb8c6..689ff74a 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -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 \ diff --git a/CMakeLists.txt b/CMakeLists.txt index d3f15ef3..6f53a167 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) diff --git a/README-CMake.md b/README-CMake.md index 29a5b014..c7dbdce2 100644 --- a/README-CMake.md +++ b/README-CMake.md @@ -9,8 +9,8 @@ To build & install everything into the specific ESP8266 Core directory: ``` $ cmake \ - --toolchain=cmake/toolchain.cmake \ - -DCMAKE_PROGRAM_PATH= \ + --toolchain=cmake/toolchain-esp8266.cmake \ + -DCMAKE_PROGRAM_PATH= \ -DESP8266_ARDUINO_CORE_DIR= \ -B build $ cmake --build build diff --git a/cmake/common.cmake b/cmake/common.cmake index 546d933f..21f061fc 100644 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -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 ) diff --git a/cmake/esp8266-platform.cmake b/cmake/platform-esp8266.cmake similarity index 100% rename from cmake/esp8266-platform.cmake rename to cmake/platform-esp8266.cmake diff --git a/cmake/toolchain.cmake b/cmake/toolchain-esp8266.cmake similarity index 70% rename from cmake/toolchain.cmake rename to cmake/toolchain-esp8266.cmake index 8f7aa31f..d58be90b 100644 --- a/cmake/toolchain.cmake +++ b/cmake/toolchain-esp8266.cmake @@ -1,6 +1,6 @@ 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) @@ -8,9 +8,9 @@ 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")