From a60fe9e507f2599211835d4fe54480f0eafaa621 Mon Sep 17 00:00:00 2001 From: Serge Bazanski <q3k@q3k.org> Date: Fri, 4 Aug 2023 15:57:31 +0200 Subject: [PATCH] *: turn floating-point literals into single-precision floats Turns out '1.1' is by default double-precision. That's a waste of resources. And we also are never going to remember to suffix this stuff. --- CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d73a12dd4..ad7425c2da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,3 +5,16 @@ set(IDF_TARGET esp32s3) include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(flow3r) + +# Make `1.1` literals into single-point precision float instead of double +# precision. Also warn any time something gets promoted to a double. We +# generally don't want doubles, doubles on ESP32 bad. +idf_component_get_property(st3m_lib st3m COMPONENT_LIB) +idf_component_get_property(flow3r_bsp_lib flow3r_bsp COMPONENT_LIB) +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + target_compile_options(${st3m_lib} PRIVATE -cl-single-precision-constant -Wdouble-promotion) + target_compile_options(${flow3r_bsp_lib} PRIVATE -cl-single-precision-constant -Wdouble-promotion) +else() + target_compile_options(${st3m_lib} PRIVATE -fsingle-precision-constant -Wdouble-promotion) + target_compile_options(${flow3r_bsp_lib} PRIVATE -fsingle-precision-constant -Wdouble-promotion) +endif() -- GitLab