Skip to content

Commit

Permalink
CMakeLists.txt: minor improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
pstolarz committed Dec 13, 2024
1 parent 7e8296c commit 104769d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
function(target_optimize_size target)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(${target} PRIVATE -Os)
endif()
endfunction()

if(IDF_VER)
# ESP-IDF
if(IDF_VERSION_MAJOR GREATER_EQUAL 5)
Expand All @@ -23,7 +30,8 @@ if(IDF_VER)
src/drivers
)
endif()
set(target ${COMPONENT_LIB})

target_optimize_size(${COMPONENT_LIB})
elseif(PICO_SDK_VERSION_STRING)
# Pico SDK
file(GLOB target_src
Expand All @@ -38,10 +46,6 @@ elseif(PICO_SDK_VERSION_STRING)
pico_stdlib
hardware_pio
)
set(target OneWireNg)
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(${target} PRIVATE -Os)
target_optimize_size(OneWireNg)
endif()

0 comments on commit 104769d

Please sign in to comment.