build system: don't add GCC-specific options when building with clang

This commit is contained in:
Ivan Grokhotkov 2021-01-20 02:15:43 +01:00
parent 06f22fc4b0
commit ed7fbfefac
5 changed files with 15 additions and 13 deletions

View File

@ -90,6 +90,13 @@ if(CONFIG_COMPILER_DUMP_RTL_FILES)
list(APPEND compile_options "-fdump-rtl-expand")
endif()
# GCC-specific options
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
list(APPEND compile_options "-fstrict-volatile-bitfields"
"-Wno-error=unused-but-set-variable"
)
endif()
list(APPEND link_options "-fno-lto")
idf_build_set_property(COMPILE_OPTIONS "${compile_options}" APPEND)

View File

@ -1,2 +1,2 @@
CONFIG_IDF_TARGET="linux"
CONFIG_CXX_EXCEPTIONS=y
CONFIG_COMPILER_CXX_EXCEPTIONS=y

View File

@ -94,12 +94,10 @@ function(__build_set_default_build_specifications)
list(APPEND compile_options "-ffunction-sections"
"-fdata-sections"
"-fstrict-volatile-bitfields"
# warning-related flags
"-Wall"
"-Werror=all"
"-Wno-error=unused-function"
"-Wno-error=unused-but-set-variable"
"-Wno-error=unused-variable"
"-Wno-error=deprecated-declarations"
"-Wextra"

View File

@ -460,8 +460,10 @@ macro(project project_name)
endif()
target_link_libraries(${project_elf} ${build_components})
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
set(mapfile "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.map")
target_link_libraries(${project_elf} "-Wl,--cref -Wl,--Map=${mapfile}")
endif()
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES

View File

@ -1,8 +1,3 @@
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_COMPILER g++)
set(CMAKE_ASM_COMPILER gcc)
set(CMAKE_C_FLAGS "-Wno-frame-address" CACHE STRING "C Compiler Base Flags")
set(CMAKE_CXX_FLAGS "-Wno-frame-address" CACHE STRING "C++ Compiler Base Flags")
# The build system assumes that toolchain-${IDF_TARGET}.cmake file
# is present. It is not necessary for the host build, so we keep
# this file as a placeholder.