mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 09:09:10 -04:00
cmake: only add GCC-specific flags when building with GCC
There are probably more GCC-specific flags in component CMakeLists.txt files; these are just the one being added for all the files.
This commit is contained in:
parent
90a87cf5e4
commit
6bba3ea034
@ -20,7 +20,9 @@ if(NOT BOOTLOADER_BUILD)
|
||||
|
||||
if(CONFIG_COMPILER_OPTIMIZATION_SIZE)
|
||||
list(APPEND compile_options "-Os")
|
||||
list(APPEND compile_options "-freorder-blocks")
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
|
||||
list(APPEND compile_options "-freorder-blocks")
|
||||
endif()
|
||||
elseif(CONFIG_COMPILER_OPTIMIZATION_DEFAULT)
|
||||
list(APPEND compile_options "-Og")
|
||||
elseif(CONFIG_COMPILER_OPTIMIZATION_NONE)
|
||||
@ -33,7 +35,9 @@ else() # BOOTLOADER_BUILD
|
||||
|
||||
if(CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE)
|
||||
list(APPEND compile_options "-Os")
|
||||
list(APPEND compile_options "-freorder-blocks")
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
|
||||
list(APPEND compile_options "-freorder-blocks")
|
||||
endif()
|
||||
elseif(CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG)
|
||||
list(APPEND compile_options "-Og")
|
||||
elseif(CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE)
|
||||
@ -74,6 +78,10 @@ if(CONFIG_COMPILER_DISABLE_GCC8_WARNINGS)
|
||||
"-Wno-int-in-bool-context")
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
|
||||
list(APPEND c_compile_options "-Wno-old-style-declaration")
|
||||
endif()
|
||||
|
||||
if(CONFIG_COMPILER_WARN_WRITE_STRINGS)
|
||||
list(APPEND compile_options "-Wwrite-strings")
|
||||
endif()
|
||||
@ -118,7 +126,15 @@ list(APPEND link_options "-fno-lto")
|
||||
# Placing jump tables in flash would cause issues with code that required
|
||||
# to be placed in IRAM
|
||||
list(APPEND compile_options "-fno-jump-tables")
|
||||
list(APPEND compile_options "-fno-tree-switch-conversion")
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
|
||||
# This flag is GCC-specific.
|
||||
# Not clear yet if some other flag should be used for Clang.
|
||||
list(APPEND compile_options "-fno-tree-switch-conversion")
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "LLVM")
|
||||
list(APPEND compile_options "-fno-use-cxa-atexit")
|
||||
endif()
|
||||
|
||||
idf_build_set_property(COMPILE_OPTIONS "${compile_options}" APPEND)
|
||||
idf_build_set_property(C_COMPILE_OPTIONS "${c_compile_options}" APPEND)
|
||||
|
@ -107,8 +107,7 @@ function(__build_set_default_build_specifications)
|
||||
# go into the final binary so have no impact on size
|
||||
"-ggdb")
|
||||
|
||||
list(APPEND c_compile_options "-std=gnu99"
|
||||
"-Wno-old-style-declaration")
|
||||
list(APPEND c_compile_options "-std=gnu99")
|
||||
|
||||
list(APPEND cxx_compile_options "-std=gnu++11")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user