mirror of https://github.com/ARMmbed/mbed-os.git
CMake: Do not hard code target in toolchain CMake module
Provide a function in each toolchain module to set the toolchain specific options. All the functions have the same interface therefore the CMake source file including the module always calls the same function regardless of which toolchain module is actually included. When the `mbed-os` target is broken up into multiple libraries, a library other than `mbed-os` might need to set the toolchain options. This will be possible by simply including the module and calling the function with the target for which to set the options.pull/13566/head
parent
c8b4822ed7
commit
cb9960cb08
|
@ -19,6 +19,7 @@ include(${MBED_ROOT}/cmake/core.cmake)
|
|||
mbed_set_cpu_core_options(mbed-os ${MBED_TOOLCHAIN})
|
||||
|
||||
include(${MBED_ROOT}/cmake/toolchain.cmake)
|
||||
mbed_set_toolchain_options(mbed-os)
|
||||
|
||||
include(${MBED_ROOT}/cmake/profile.cmake)
|
||||
|
||||
|
|
|
@ -13,47 +13,52 @@ if(MBEDIDE)
|
|||
set_property(GLOBAL PROPERTY MBED_STUDIO_ARM_COMPILER "--ide=mbed")
|
||||
endif()
|
||||
|
||||
list(APPEND common_options
|
||||
"${mbed_studio_arm_compiler}"
|
||||
"-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"
|
||||
)
|
||||
|
||||
target_compile_options(mbed-os
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:C>:${common_options}>
|
||||
)
|
||||
# Sets toolchain options
|
||||
function(mbed_set_toolchain_options target)
|
||||
get_property(mbed_studio_arm_compiler GLOBAL PROPERTY MBED_STUDIO_ARM_COMPILER)
|
||||
list(APPEND common_options
|
||||
"${mbed_studio_arm_compiler}"
|
||||
"-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"
|
||||
)
|
||||
|
||||
target_compile_options(mbed-os
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:CXX>:${common_options}>
|
||||
)
|
||||
target_compile_options(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:C>:${common_options}>
|
||||
)
|
||||
|
||||
set(asm_preproc_options
|
||||
"--target=arm-arm-none-eabi,-D,MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED"
|
||||
)
|
||||
target_compile_options(mbed-os
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:ASM>:${MBED_STUDIO_ARM_COMPILER}>
|
||||
$<$<COMPILE_LANGUAGE:ASM>:--cpreproc>
|
||||
$<$<COMPILE_LANGUAGE:ASM>:--cpreproc_opts=${asm_preproc_options}>
|
||||
)
|
||||
target_compile_options(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:CXX>:${common_options}>
|
||||
)
|
||||
|
||||
target_compile_definitions(mbed-os
|
||||
PUBLIC
|
||||
TOOLCHAIN_ARM
|
||||
)
|
||||
set(asm_preproc_options
|
||||
"--target=arm-arm-none-eabi,-D,MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED"
|
||||
)
|
||||
target_compile_options(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:ASM>:${MBED_STUDIO_ARM_COMPILER}>
|
||||
$<$<COMPILE_LANGUAGE:ASM>:--cpreproc>
|
||||
$<$<COMPILE_LANGUAGE:ASM>:--cpreproc_opts=${asm_preproc_options}>
|
||||
)
|
||||
|
||||
target_link_options(mbed-os
|
||||
PUBLIC
|
||||
${MBED_STUDIO_ARM_COMPILER}
|
||||
)
|
||||
target_compile_definitions(${target}
|
||||
PUBLIC
|
||||
TOOLCHAIN_ARM
|
||||
)
|
||||
|
||||
target_link_options(${target}
|
||||
PUBLIC
|
||||
${MBED_STUDIO_ARM_COMPILER}
|
||||
)
|
||||
endfunction()
|
||||
|
|
|
@ -7,47 +7,51 @@ set(CMAKE_CXX_COMPILER "arm-none-eabi-g++")
|
|||
set(GCC_ELF2BIN "arm-none-eabi-objcopy")
|
||||
set_property(GLOBAL PROPERTY ELF2BIN ${GCC_ELF2BIN})
|
||||
|
||||
list(APPEND link_options
|
||||
"-Wl,--start-group"
|
||||
"-lstdc++"
|
||||
"-lsupc++"
|
||||
"-lm"
|
||||
"-lc"
|
||||
"-lgcc"
|
||||
"-lnosys"
|
||||
"-Wl,--end-group"
|
||||
"-specs=nosys.specs"
|
||||
"-T" "${CMAKE_BINARY_DIR}/${APP_TARGET}.link_script.ld"
|
||||
)
|
||||
|
||||
list(APPEND common_options
|
||||
"-Wall"
|
||||
"-Wextra"
|
||||
"-Wno-unused-parameter"
|
||||
"-Wno-missing-field-initializers"
|
||||
"-fmessage-length=0"
|
||||
"-fno-exceptions"
|
||||
"-ffunction-sections"
|
||||
"-fdata-sections"
|
||||
"-funsigned-char"
|
||||
"-MMD"
|
||||
"-fomit-frame-pointer"
|
||||
"-g3"
|
||||
)
|
||||
# Sets toolchain options
|
||||
function(mbed_set_toolchain_options target)
|
||||
list(APPEND link_options
|
||||
"-Wl,--start-group"
|
||||
"-lstdc++"
|
||||
"-lsupc++"
|
||||
"-lm"
|
||||
"-lc"
|
||||
"-lgcc"
|
||||
"-lnosys"
|
||||
"-Wl,--end-group"
|
||||
"-specs=nosys.specs"
|
||||
"-T" "${CMAKE_BINARY_DIR}/${APP_TARGET}.link_script.ld"
|
||||
)
|
||||
|
||||
target_compile_options(mbed-os
|
||||
PUBLIC
|
||||
${common_options}
|
||||
)
|
||||
list(APPEND common_options
|
||||
"-Wall"
|
||||
"-Wextra"
|
||||
"-Wno-unused-parameter"
|
||||
"-Wno-missing-field-initializers"
|
||||
"-fmessage-length=0"
|
||||
"-fno-exceptions"
|
||||
"-ffunction-sections"
|
||||
"-fdata-sections"
|
||||
"-funsigned-char"
|
||||
"-MMD"
|
||||
"-fomit-frame-pointer"
|
||||
"-g3"
|
||||
)
|
||||
|
||||
target_compile_definitions(mbed-os
|
||||
PUBLIC
|
||||
TOOLCHAIN_GCC_ARM
|
||||
TOOLCHAIN_GCC
|
||||
)
|
||||
target_compile_options(${target}
|
||||
PUBLIC
|
||||
${common_options}
|
||||
)
|
||||
|
||||
target_link_options(mbed-os
|
||||
PUBLIC
|
||||
${common_options}
|
||||
${link_options}
|
||||
)
|
||||
target_compile_definitions(${target}
|
||||
PUBLIC
|
||||
TOOLCHAIN_GCC_ARM
|
||||
TOOLCHAIN_GCC
|
||||
)
|
||||
|
||||
target_link_options(${target}
|
||||
PUBLIC
|
||||
${common_options}
|
||||
${link_options}
|
||||
)
|
||||
endfunction()
|
||||
|
|
Loading…
Reference in New Issue