-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IAR CMake native support #2376
Merged
Merged
IAR CMake native support #2376
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,7 +72,7 @@ set(WARNING_FLAGS_GNU | |
-Wredundant-decls | ||
) | ||
|
||
set(WARNINGS_FLAGS_IAR "") | ||
set(WARNING_FLAGS_IAR "") | ||
|
||
|
||
# Filter example based on only.txt and skip.txt | ||
|
@@ -191,10 +191,12 @@ function(family_configure_common TARGET RTOS) | |
) | ||
|
||
# run size after build | ||
add_custom_command(TARGET ${TARGET} POST_BUILD | ||
COMMAND ${CMAKE_SIZE} $<TARGET_FILE:${TARGET}> | ||
) | ||
|
||
find_program(SIZE_EXE ${CMAKE_SIZE}) | ||
if(NOT ${SIZE_EXE} STREQUAL SIZE_EXE-NOTFOUND) | ||
add_custom_command(TARGET ${TARGET} POST_BUILD | ||
COMMAND ${SIZE_EXE} $<TARGET_FILE:${TARGET}> | ||
) | ||
endif () | ||
# Add warnings flags | ||
target_compile_options(${TARGET} PUBLIC ${WARNING_FLAGS_${CMAKE_C_COMPILER_ID}}) | ||
|
||
|
@@ -205,6 +207,10 @@ function(family_configure_common TARGET RTOS) | |
target_link_options(${TARGET} PUBLIC "LINKER:--no-warn-rwx-segments") | ||
endif () | ||
endif() | ||
if (CMAKE_C_COMPILER_ID STREQUAL "IAR") | ||
target_link_options(${TARGET} PUBLIC "LINKER:--map=$<TARGET_FILE:${TARGET}>.map") | ||
endif() | ||
|
||
|
||
# ETM Trace option | ||
if (TRACE_ETM STREQUAL "1") | ||
|
@@ -367,7 +373,7 @@ function(family_flash_jlink TARGET) | |
endif () | ||
|
||
file(GENERATE | ||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.jlink | ||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${TARGET}.jlink | ||
CONTENT "halt | ||
loadfile $<TARGET_FILE:${TARGET}> | ||
r | ||
|
@@ -377,7 +383,7 @@ exit" | |
|
||
add_custom_target(${TARGET}-jlink | ||
DEPENDS ${TARGET} | ||
COMMAND ${JLINKEXE} -device ${JLINK_DEVICE} -if swd -JTAGConf -1,-1 -speed auto -CommandFile ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.jlink | ||
COMMAND ${JLINKEXE} -device ${JLINK_DEVICE} -if swd -JTAGConf -1,-1 -speed auto -CommandFile ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${TARGET}.jlink | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to change as well, though please try the new |
||
) | ||
endfunction() | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does IAR has 1 config per folder within the build dir. Normally clion has 1 build dir per config. If possible, change it to
{TARGET}_$<CONFIG>.jlink
would be better.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes each binary has it's own folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, for clion, I typically use one build dir per config.
I think maybe we can use
$<TARGET_FILE_DIR:${TARGET}>
instead of of${CMAKE_CURRENT_BINARY_DIR}
for the flash target as below, please try to see if that work for you. It should expand to parent folder of the exe file (within each config for IAR)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It gives something like this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perfect, it is what we want the .jlink file in the same folder of the elf for both IAR Workbecnh and clion. Not sure if IAR can execute the -jlink target, if it does, it should be able to flash your board with correct elf.
Please push the update, it is all good now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Currently CMake support is pretty primitive, it defaults to Ninja multi config generator and there is no option for pre/post build actions. And I had multiple crashes modifying CMake file.
I'm going to give them some feedbacks.