Skip to content

Commit fcf7791

Browse files
committed
add IAR support for G0 with cmake
1 parent e7090c7 commit fcf7791

File tree

21 files changed

+196
-145
lines changed

21 files changed

+196
-145
lines changed

examples/device/net_lwip_webserver/CMakeLists.txt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,16 @@ target_sources(${PROJECT} PUBLIC
7777
)
7878

7979
# due to warnings from other net source, we need to prevent error from some of the warnings options
80-
target_compile_options(${PROJECT} PUBLIC
81-
-Wno-error=null-dereference
82-
-Wno-error=conversion
83-
-Wno-error=sign-conversion
84-
-Wno-error=sign-compare
85-
)
80+
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
81+
target_compile_options(${PROJECT} PUBLIC
82+
-Wno-error=null-dereference
83+
-Wno-error=conversion
84+
-Wno-error=sign-conversion
85+
-Wno-error=sign-compare
86+
)
87+
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
88+
89+
endif ()
8690

8791
# Configure compilation flags and libraries for the example... see the corresponding function
8892
# in hw/bsp/FAMILY/family.cmake for details.

hw/bsp/family_support.cmake

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -97,53 +97,6 @@ function(family_initialize_project PROJECT DIR)
9797
endfunction()
9898

9999

100-
function(family_add_default_example_warnings TARGET)
101-
target_compile_options(${TARGET} PUBLIC
102-
-Wall
103-
-Wextra
104-
-Werror
105-
-Wfatal-errors
106-
-Wdouble-promotion
107-
-Wfloat-equal
108-
-Wshadow
109-
-Wwrite-strings
110-
-Wsign-compare
111-
-Wmissing-format-attribute
112-
-Wunreachable-code
113-
-Wcast-align
114-
-Wcast-qual
115-
-Wnull-dereference
116-
-Wuninitialized
117-
-Wunused
118-
-Wredundant-decls
119-
#-Wstrict-prototypes
120-
#-Werror-implicit-function-declaration
121-
#-Wundef
122-
)
123-
124-
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
125-
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0)
126-
target_link_options(${TARGET} PUBLIC "LINKER:--no-warn-rwx-segments")
127-
endif()
128-
129-
# GCC 10
130-
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)
131-
target_compile_options(${TARGET} PUBLIC -Wconversion)
132-
endif()
133-
134-
# GCC 8
135-
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
136-
target_compile_options(${TARGET} PUBLIC -Wcast-function-type -Wstrict-overflow)
137-
endif()
138-
139-
# GCC 6
140-
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0)
141-
target_compile_options(${TARGET} PUBLIC -Wno-strict-aliasing)
142-
endif()
143-
endif()
144-
endfunction()
145-
146-
147100
#------------------------------------
148101
# Main target configure
149102
#------------------------------------
@@ -155,11 +108,13 @@ function(family_configure_common TARGET)
155108
COMMAND ${CMAKE_SIZE} $<TARGET_FILE:${TARGET}>
156109
)
157110

158-
# Generate map file
159-
target_link_options(${TARGET} PUBLIC
160-
# link map
161-
"LINKER:-Map=$<TARGET_FILE:${TARGET}>.map"
162-
)
111+
if (CMAKE_C_COMPILER_ID STREQUAL "GCC")
112+
# Generate map file
113+
target_link_options(${TARGET} PUBLIC
114+
# link map
115+
"LINKER:-Map=$<TARGET_FILE:${TARGET}>.map"
116+
)
117+
endif()
163118
endfunction()
164119

165120

@@ -198,7 +153,7 @@ function(family_add_freertos TARGET)
198153
# freeros config
199154
if (NOT TARGET freertos_config)
200155
add_library(freertos_config INTERFACE)
201-
target_include_directories(freertos_config SYSTEM INTERFACE
156+
target_include_directories(freertos_config INTERFACE
202157
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${FAMILY}/FreeRTOSConfig
203158
)
204159
endif()
@@ -223,6 +178,53 @@ function(family_add_freertos TARGET)
223178
endfunction()
224179

225180

181+
function(family_add_default_example_warnings TARGET)
182+
target_compile_options(${TARGET} PUBLIC
183+
-Wall
184+
-Wextra
185+
-Werror
186+
-Wfatal-errors
187+
-Wdouble-promotion
188+
-Wfloat-equal
189+
-Wshadow
190+
-Wwrite-strings
191+
-Wsign-compare
192+
-Wmissing-format-attribute
193+
-Wunreachable-code
194+
-Wcast-align
195+
-Wcast-qual
196+
-Wnull-dereference
197+
-Wuninitialized
198+
-Wunused
199+
-Wredundant-decls
200+
#-Wstrict-prototypes
201+
#-Werror-implicit-function-declaration
202+
#-Wundef
203+
)
204+
205+
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
206+
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0)
207+
target_link_options(${TARGET} PUBLIC "LINKER:--no-warn-rwx-segments")
208+
endif()
209+
210+
# GCC 10
211+
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)
212+
target_compile_options(${TARGET} PUBLIC -Wconversion)
213+
endif()
214+
215+
# GCC 8
216+
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
217+
target_compile_options(${TARGET} PUBLIC -Wcast-function-type -Wstrict-overflow)
218+
endif()
219+
220+
# GCC 6
221+
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0)
222+
target_compile_options(${TARGET} PUBLIC -Wno-strict-aliasing)
223+
endif()
224+
endif()
225+
endfunction()
226+
227+
226228
# Add bin/hex output
227229
function(family_add_bin_hex TARGET)
228230
add_custom_command(TARGET ${TARGET} POST_BUILD

hw/bsp/imxrt/family.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ if (NOT TARGET ${BOARD_TARGET})
5353
update_board(${BOARD_TARGET})
5454

5555
if (NOT DEFINED LD_FILE_${TOOLCHAIN})
56-
set(LD_FILE_gcc ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_VARIANT}xxxxx_flexspi_nor.ld)
56+
set(LD_FILE_GCC ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_VARIANT}xxxxx_flexspi_nor.ld)
5757
endif ()
5858

5959
if (TOOLCHAIN STREQUAL "gcc")
6060
target_sources(${BOARD_TARGET} PUBLIC
6161
${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_VARIANT}.S
6262
)
6363
target_link_options(${BOARD_TARGET} PUBLIC
64-
"LINKER:--script=${LD_FILE_gcc}"
64+
"LINKER:--script=${LD_FILE_GCC}"
6565
# nanolib
6666
--specs=nosys.specs
6767
--specs=nano.specs

hw/bsp/lpc18/boards/lpcxpresso18s37/board.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set(JLINK_DEVICE LPC18S37)
44
set(PYOCD_TARGET LPC18S37)
55
set(NXPLINK_DEVICE LPC18S37:LPCXPRESSO18S37)
66

7-
set(LD_FILE_gcc ${CMAKE_CURRENT_LIST_DIR}/lpc1837.ld)
7+
set(LD_FILE_GCC ${CMAKE_CURRENT_LIST_DIR}/lpc1837.ld)
88

99
function(update_board TARGET)
1010
# nothing to do

hw/bsp/lpc18/boards/mcb1800/board.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set(JLINK_DEVICE LPC1857)
44
set(PYOCD_TARGET LPC1857)
55
set(NXPLINK_DEVICE LPC1857:MCB1857)
66

7-
set(LD_FILE_gcc ${CMAKE_CURRENT_LIST_DIR}/lpc1857.ld)
7+
set(LD_FILE_GCC ${CMAKE_CURRENT_LIST_DIR}/lpc1857.ld)
88

99
function(update_board TARGET)
1010
# nothing to do

hw/bsp/lpc18/family.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ if (NOT TARGET ${BOARD_TARGET})
4848

4949
if (TOOLCHAIN STREQUAL "gcc")
5050
target_link_options(${BOARD_TARGET} PUBLIC
51-
"LINKER:--script=${LD_FILE_gcc}"
51+
"LINKER:--script=${LD_FILE_GCC}"
5252
# nanolib
5353
--specs=nosys.specs
5454
--specs=nano.specs

hw/bsp/lpc55/boards/double_m33_express/board.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set(JLINK_DEVICE LPC55S69)
55
set(PYOCD_TARGET LPC55S69)
66
set(NXPLINK_DEVICE LPC55S69:LPCXpresso55S69)
77

8-
set(LD_FILE_gcc ${CMAKE_CURRENT_LIST_DIR}/LPC55S69_cm33_core0_uf2.ld)
8+
set(LD_FILE_GCC ${CMAKE_CURRENT_LIST_DIR}/LPC55S69_cm33_core0_uf2.ld)
99

1010
function(update_board TARGET)
1111
target_compile_definitions(${TARGET} PUBLIC

hw/bsp/lpc55/family.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ if (NOT TARGET ${BOARD_TARGET})
6565
update_board(${BOARD_TARGET})
6666

6767
if (NOT DEFINED LD_FILE_${TOOLCHAIN})
68-
set(LD_FILE_gcc ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_CORE}_flash.ld)
68+
set(LD_FILE_GCC ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_CORE}_flash.ld)
6969
endif ()
7070

7171
if (TOOLCHAIN STREQUAL "gcc")
@@ -74,7 +74,7 @@ if (NOT TARGET ${BOARD_TARGET})
7474
)
7575
target_link_options(${BOARD_TARGET} PUBLIC
7676
# linker file
77-
"LINKER:--script=${LD_FILE_gcc}"
77+
"LINKER:--script=${LD_FILE_GCC}"
7878
# nanolib
7979
--specs=nosys.specs
8080
--specs=nano.specs

hw/bsp/nrf/boards/pca10056/board.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
set(MCU_VARIANT nrf52840)
2-
set(LD_FILE_gcc ${NRFX_DIR}/mdk/nrf52840_xxaa.ld)
2+
set(LD_FILE_GCC ${NRFX_DIR}/mdk/nrf52840_xxaa.ld)
33

44
function(update_board TARGET)
55
target_compile_definitions(${TARGET} PUBLIC

hw/bsp/nrf/boards/pca10095/board.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
set(MCU_VARIANT nrf5340_application)
2-
set(LD_FILE_gcc ${NRFX_DIR}/mdk/nrf5340_xxaa_application.ld)
2+
set(LD_FILE_GCC ${NRFX_DIR}/mdk/nrf5340_xxaa_application.ld)
33

44
function(update_board TARGET)
55
target_compile_definitions(${TARGET} PUBLIC

0 commit comments

Comments
 (0)