Skip to content
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

CMake: Set required toolchain and processor flags globally, instead of per-target #13987

Merged
merged 9 commits into from
Dec 10, 2020
58 changes: 25 additions & 33 deletions tools/cmake/toolchains/ARM.cmake
Original file line number Diff line number Diff line change
@@ -8,48 +8,40 @@ set(CMAKE_AR "armar")
set(ARM_ELF2BIN "fromelf")
set_property(GLOBAL PROPERTY ELF2BIN ${ARM_ELF2BIN})

# Sets toolchain options
function(mbed_set_toolchain_options target)
list(APPEND common_options
"-c"
"--target=arm-arm-none-eabi"
"-mthumb"
"-Wno-armcc-pragma-push-pop"
"-Wno-armcc-pragma-anon-unions"
"-Wno-reserved-user-defined-literal"
"-Wno-deprecated-register"
"-fdata-sections"
"-fno-exceptions"
"-fshort-enums"
"-fshort-wchar"
)
# tell cmake about compiler targets.
# This will cause it to add the --target flag.
set(CMAKE_C_COMPILER_TARGET arm-arm-none-eabi)
set(CMAKE_CXX_COMPILER_TARGET arm-arm-none-eabi)

target_compile_options(${target}
INTERFACE
$<$<COMPILE_LANGUAGE:C>:${common_options}>
# Sets toolchain options
list(APPEND common_options
"-mthumb"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-c was removed as it's not required, just checking if it was intentionally removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep that was intentional, CMake will add -c as needed.

"-Wno-armcc-pragma-push-pop"
"-Wno-armcc-pragma-anon-unions"
"-Wno-reserved-user-defined-literal"
"-Wno-deprecated-register"
"-fdata-sections"
"-fno-exceptions"
"-fshort-enums"
"-fshort-wchar"
)

target_compile_options(${target}
INTERFACE
$<$<COMPILE_LANGUAGE:CXX>:${common_options}>
list(APPEND asm_compile_options
-masm=auto
--target=arm-arm-none-eabi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's not CMAKE_ASM_COMPILER_TARGET as we do above for C/CXX ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe so... though it kinda depends on how ARM implemented the CMake scripts for ARM Compiler. You could try adding it (and removing the manual --target flag) and see if it works.

)

target_compile_options(${target}
INTERFACE
$<$<COMPILE_LANGUAGE:ASM>:--target=arm-arm-none-eabi -masm=auto>
list(APPEND link_options
"--map"
)

# Add linking time preprocessor macro for TFM targets
if(MBED_CPU_CORE MATCHES "\-NS$")
list(APPEND link_options
"--predefine=\"-DDOMAIN_NS=0x1\""
# Add linking time preprocessor macro for TFM targets
if(MBED_CPU_CORE MATCHES "-NS$")
)
endif()
endif()

target_link_options(${target}
INTERFACE
${link_options}
)
function(mbed_set_toolchain_options target)
# blank for ARMClang
endfunction()

# Configure the toolchain to select the selected C library