mirror of https://github.com/ARMmbed/mbed-os.git
CMake: Do not hard code target in build profile CMake module
Provide a function in each build profile module to set the toolchain options. All the functions have the same interface therefore the CMake source file including the module always calls the same function regardless of which build profile 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 and toolchain for which to set the options.pull/13566/head
parent
cb9960cb08
commit
dde395c82f
|
@ -22,6 +22,7 @@ include(${MBED_ROOT}/cmake/toolchain.cmake)
|
|||
mbed_set_toolchain_options(mbed-os)
|
||||
|
||||
include(${MBED_ROOT}/cmake/profile.cmake)
|
||||
mbed_set_profile_options(mbed-os ${MBED_TOOLCHAIN})
|
||||
|
||||
include(${MBED_ROOT}/cmake/util.cmake)
|
||||
|
||||
|
|
|
@ -1,96 +1,99 @@
|
|||
# Copyright (c) 2020 ARM Limited. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
list(APPEND link_options)
|
||||
# Sets profile options
|
||||
function(mbed_set_profile_options target mbed_toolchain)
|
||||
list(APPEND link_options)
|
||||
|
||||
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
|
||||
list(APPEND c_compile_options
|
||||
"-c"
|
||||
"-std=gnu11"
|
||||
"-Og"
|
||||
)
|
||||
target_compile_options(mbed-os
|
||||
if(${mbed_toolchain} STREQUAL "GCC_ARM")
|
||||
list(APPEND c_compile_options
|
||||
"-c"
|
||||
"-std=gnu11"
|
||||
"-Og"
|
||||
)
|
||||
target_compile_options(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:C>:${c_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND cxx_compile_options
|
||||
"-c"
|
||||
"-std=gnu++14"
|
||||
"-fno-rtti"
|
||||
"-Wvla"
|
||||
"-Og"
|
||||
)
|
||||
target_compile_options(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:CXX>:${cxx_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND asm_compile_options
|
||||
"-c"
|
||||
"-x" "assembler-with-cpp"
|
||||
)
|
||||
target_compile_options(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:ASM>:${asm_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND link_options
|
||||
"-Wl,--gc-sections"
|
||||
"-Wl,--wrap,main"
|
||||
"-Wl,--wrap,_malloc_r"
|
||||
"-Wl,--wrap,_free_r"
|
||||
"-Wl,--wrap,_realloc_r"
|
||||
"-Wl,--wrap,_memalign_r"
|
||||
"-Wl,--wrap,_calloc_r"
|
||||
"-Wl,--wrap,exit"
|
||||
"-Wl,--wrap,atexit"
|
||||
"-Wl,-n"
|
||||
)
|
||||
elseif(${mbed_toolchain} STREQUAL "ARM")
|
||||
list(APPEND c_compile_options
|
||||
"-std=gnu11"
|
||||
"-O1"
|
||||
)
|
||||
target_compile_options(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:C>:${c_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND cxx_compile_options
|
||||
"-std=gnu++14"
|
||||
"-fno-rtti"
|
||||
"-fno-c++-static-destructors"
|
||||
"-O1"
|
||||
)
|
||||
target_compile_options(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:CXX>:${cxx_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND link_options
|
||||
"--verbose"
|
||||
"--remove"
|
||||
"--show_full_path"
|
||||
"--legacyalign"
|
||||
"--any_contingency"
|
||||
"--keep=os_cb_sections"
|
||||
)
|
||||
|
||||
target_compile_definitions(${target}
|
||||
PUBLIC
|
||||
__ASSERT_MSG
|
||||
MULADDC_CANNOT_USE_R7
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:C>:${c_compile_options}>
|
||||
MBED_DEBUG
|
||||
MBED_TRAP_ERRORS_ENABLED=1
|
||||
)
|
||||
|
||||
list(APPEND cxx_compile_options
|
||||
"-c"
|
||||
"-std=gnu++14"
|
||||
"-fno-rtti"
|
||||
"-Wvla"
|
||||
"-Og"
|
||||
)
|
||||
target_compile_options(mbed-os
|
||||
target_link_options(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:CXX>:${cxx_compile_options}>
|
||||
${link_options}
|
||||
)
|
||||
|
||||
list(APPEND asm_compile_options
|
||||
"-c"
|
||||
"-x" "assembler-with-cpp"
|
||||
)
|
||||
target_compile_options(mbed-os
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:ASM>:${asm_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND link_options
|
||||
"-Wl,--gc-sections"
|
||||
"-Wl,--wrap,main"
|
||||
"-Wl,--wrap,_malloc_r"
|
||||
"-Wl,--wrap,_free_r"
|
||||
"-Wl,--wrap,_realloc_r"
|
||||
"-Wl,--wrap,_memalign_r"
|
||||
"-Wl,--wrap,_calloc_r"
|
||||
"-Wl,--wrap,exit"
|
||||
"-Wl,--wrap,atexit"
|
||||
"-Wl,-n"
|
||||
)
|
||||
elseif(MBED_TOOLCHAIN STREQUAL "ARM")
|
||||
list(APPEND c_compile_options
|
||||
"-std=gnu11"
|
||||
"-O1"
|
||||
)
|
||||
target_compile_options(mbed-os
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:C>:${c_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND cxx_compile_options
|
||||
"-std=gnu++14"
|
||||
"-fno-rtti"
|
||||
"-fno-c++-static-destructors"
|
||||
"-O1"
|
||||
)
|
||||
target_compile_options(mbed-os
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:CXX>:${cxx_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND link_options
|
||||
"--verbose"
|
||||
"--remove"
|
||||
"--show_full_path"
|
||||
"--legacyalign"
|
||||
"--any_contingency"
|
||||
"--keep=os_cb_sections"
|
||||
)
|
||||
|
||||
target_compile_definitions(mbed-os
|
||||
PUBLIC
|
||||
__ASSERT_MSG
|
||||
MULADDC_CANNOT_USE_R7
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(mbed-os
|
||||
PUBLIC
|
||||
MBED_DEBUG
|
||||
MBED_TRAP_ERRORS_ENABLED=1
|
||||
)
|
||||
|
||||
target_link_options(mbed-os
|
||||
PUBLIC
|
||||
${link_options}
|
||||
)
|
||||
endfunction()
|
||||
|
|
|
@ -1,91 +1,94 @@
|
|||
# Copyright (c) 2020 ARM Limited. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
list(APPEND link_options)
|
||||
# Sets profile options
|
||||
function(mbed_set_profile_options target mbed_toolchain)
|
||||
list(APPEND link_options)
|
||||
|
||||
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
|
||||
list(APPEND c_compile_options
|
||||
"-c"
|
||||
"-std=gnu11"
|
||||
"-Os"
|
||||
)
|
||||
target_compile_options(mbed-os
|
||||
if(${mbed_toolchain} STREQUAL "GCC_ARM")
|
||||
list(APPEND c_compile_options
|
||||
"-c"
|
||||
"-std=gnu11"
|
||||
"-Os"
|
||||
)
|
||||
target_compile_options(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:C>:${c_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND cxx_compile_options
|
||||
"-std=gnu++14"
|
||||
"-fno-rtti"
|
||||
"-Wvla"
|
||||
"-Os"
|
||||
)
|
||||
target_compile_options(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:CXX>:${cxx_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND asm_compile_options
|
||||
"-x" "assembler-with-cpp"
|
||||
)
|
||||
target_compile_options(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:ASM>:${asm_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND link_options
|
||||
"-Wl,--gc-sections"
|
||||
"-Wl,--wrap,main"
|
||||
"-Wl,--wrap,_malloc_r"
|
||||
"-Wl,--wrap,_free_r"
|
||||
"-Wl,--wrap,_realloc_r"
|
||||
"-Wl,--wrap,_memalign_r"
|
||||
"-Wl,--wrap,_calloc_r"
|
||||
"-Wl,--wrap,exit"
|
||||
"-Wl,--wrap,atexit"
|
||||
"-Wl,-n"
|
||||
)
|
||||
elseif(${mbed_toolchain} STREQUAL "ARM")
|
||||
list(APPEND c_compile_options
|
||||
"-std=gnu11"
|
||||
"-Os"
|
||||
)
|
||||
target_compile_options(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:C>:${c_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND cxx_compile_options
|
||||
"-std=gnu++14"
|
||||
"-fno-rtti"
|
||||
"-fno-c++-static-destructors"
|
||||
"-Os"
|
||||
)
|
||||
target_compile_options(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:CXX>:${cxx_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND link_options
|
||||
"--show_full_path"
|
||||
"--legacyalign"
|
||||
"--inline"
|
||||
"--any_contingency"
|
||||
"--keep=os_cb_sections"
|
||||
)
|
||||
|
||||
target_compile_definitions(${target}
|
||||
PUBLIC
|
||||
__ASSERT_MSG
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:C>:${c_compile_options}>
|
||||
MBED_TRAP_ERRORS_ENABLED=1
|
||||
)
|
||||
|
||||
list(APPEND cxx_compile_options
|
||||
"-std=gnu++14"
|
||||
"-fno-rtti"
|
||||
"-Wvla"
|
||||
"-Os"
|
||||
)
|
||||
target_compile_options(mbed-os
|
||||
target_link_options(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:CXX>:${cxx_compile_options}>
|
||||
${link_options}
|
||||
)
|
||||
|
||||
list(APPEND asm_compile_options
|
||||
"-x" "assembler-with-cpp"
|
||||
)
|
||||
target_compile_options(mbed-os
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:ASM>:${asm_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND link_options
|
||||
"-Wl,--gc-sections"
|
||||
"-Wl,--wrap,main"
|
||||
"-Wl,--wrap,_malloc_r"
|
||||
"-Wl,--wrap,_free_r"
|
||||
"-Wl,--wrap,_realloc_r"
|
||||
"-Wl,--wrap,_memalign_r"
|
||||
"-Wl,--wrap,_calloc_r"
|
||||
"-Wl,--wrap,exit"
|
||||
"-Wl,--wrap,atexit"
|
||||
"-Wl,-n"
|
||||
)
|
||||
elseif(MBED_TOOLCHAIN STREQUAL "ARM")
|
||||
list(APPEND c_compile_options
|
||||
"-std=gnu11"
|
||||
"-Os"
|
||||
)
|
||||
target_compile_options(mbed-os
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:C>:${c_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND cxx_compile_options
|
||||
"-std=gnu++14"
|
||||
"-fno-rtti"
|
||||
"-fno-c++-static-destructors"
|
||||
"-Os"
|
||||
)
|
||||
target_compile_options(mbed-os
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:CXX>:${cxx_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND link_options
|
||||
"--show_full_path"
|
||||
"--legacyalign"
|
||||
"--inline"
|
||||
"--any_contingency"
|
||||
"--keep=os_cb_sections"
|
||||
)
|
||||
|
||||
target_compile_definitions(mbed-os
|
||||
PUBLIC
|
||||
__ASSERT_MSG
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(mbed-os
|
||||
PUBLIC
|
||||
MBED_TRAP_ERRORS_ENABLED=1
|
||||
)
|
||||
|
||||
target_link_options(mbed-os
|
||||
PUBLIC
|
||||
${link_options}
|
||||
)
|
||||
endfunction()
|
||||
|
|
|
@ -1,93 +1,96 @@
|
|||
# Copyright (c) 2020 ARM Limited. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
list(APPEND link_options)
|
||||
# Sets profile options
|
||||
function(mbed_set_profile_options target mbed_toolchain)
|
||||
list(APPEND link_options)
|
||||
|
||||
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
|
||||
list(APPEND c_compile_options
|
||||
"-c"
|
||||
"-std=gnu11"
|
||||
"-Os"
|
||||
)
|
||||
target_compile_options(mbed-os
|
||||
if(${mbed_toolchain} STREQUAL "GCC_ARM")
|
||||
list(APPEND c_compile_options
|
||||
"-c"
|
||||
"-std=gnu11"
|
||||
"-Os"
|
||||
)
|
||||
target_compile_options(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:C>:${c_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND cxx_compile_options
|
||||
"-c"
|
||||
"-std=gnu++14"
|
||||
"-fno-rtti"
|
||||
"-Wvla"
|
||||
"-Os"
|
||||
)
|
||||
target_compile_options(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:CXX>:${cxx_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND asm_compile_options
|
||||
"-c"
|
||||
"-x" "assembler-with-cpp"
|
||||
)
|
||||
target_compile_options(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:ASM>:${asm_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND link_options
|
||||
"-Wl,--gc-sections"
|
||||
"-Wl,--wrap,main"
|
||||
"-Wl,--wrap,_malloc_r"
|
||||
"-Wl,--wrap,_free_r"
|
||||
"-Wl,--wrap,_realloc_r"
|
||||
"-Wl,--wrap,_memalign_r"
|
||||
"-Wl,--wrap,_calloc_r"
|
||||
"-Wl,--wrap,exit"
|
||||
"-Wl,--wrap,atexit"
|
||||
"-Wl,-n"
|
||||
)
|
||||
elseif(${mbed_toolchain} STREQUAL "ARM")
|
||||
list(APPEND c_compile_options
|
||||
"-std=gnu11"
|
||||
"-Oz"
|
||||
)
|
||||
target_compile_options(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:C>:${c_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND cxx_compile_options
|
||||
"-std=gnu++14"
|
||||
"-fno-rtti"
|
||||
"-fno-c++-static-destructors"
|
||||
"-Oz"
|
||||
)
|
||||
target_compile_options(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:CXX>:${cxx_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND link_options
|
||||
"--show_full_path"
|
||||
"--legacyalign"
|
||||
"--inline"
|
||||
"--any_contingency"
|
||||
"--keep=os_cb_sections"
|
||||
)
|
||||
|
||||
target_compile_definitions(${target}
|
||||
PUBLIC
|
||||
__ASSERT_MSG
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:C>:${c_compile_options}>
|
||||
NDEBUG
|
||||
)
|
||||
|
||||
list(APPEND cxx_compile_options
|
||||
"-c"
|
||||
"-std=gnu++14"
|
||||
"-fno-rtti"
|
||||
"-Wvla"
|
||||
"-Os"
|
||||
)
|
||||
target_compile_options(mbed-os
|
||||
target_link_options(${target}
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:CXX>:${cxx_compile_options}>
|
||||
${link_options}
|
||||
)
|
||||
|
||||
list(APPEND asm_compile_options
|
||||
"-c"
|
||||
"-x" "assembler-with-cpp"
|
||||
)
|
||||
target_compile_options(mbed-os
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:ASM>:${asm_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND link_options
|
||||
"-Wl,--gc-sections"
|
||||
"-Wl,--wrap,main"
|
||||
"-Wl,--wrap,_malloc_r"
|
||||
"-Wl,--wrap,_free_r"
|
||||
"-Wl,--wrap,_realloc_r"
|
||||
"-Wl,--wrap,_memalign_r"
|
||||
"-Wl,--wrap,_calloc_r"
|
||||
"-Wl,--wrap,exit"
|
||||
"-Wl,--wrap,atexit"
|
||||
"-Wl,-n"
|
||||
)
|
||||
elseif(MBED_TOOLCHAIN STREQUAL "ARM")
|
||||
list(APPEND c_compile_options
|
||||
"-std=gnu11"
|
||||
"-Oz"
|
||||
)
|
||||
target_compile_options(mbed-os
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:C>:${c_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND cxx_compile_options
|
||||
"-std=gnu++14"
|
||||
"-fno-rtti"
|
||||
"-fno-c++-static-destructors"
|
||||
"-Oz"
|
||||
)
|
||||
target_compile_options(mbed-os
|
||||
PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:CXX>:${cxx_compile_options}>
|
||||
)
|
||||
|
||||
list(APPEND link_options
|
||||
"--show_full_path"
|
||||
"--legacyalign"
|
||||
"--inline"
|
||||
"--any_contingency"
|
||||
"--keep=os_cb_sections"
|
||||
)
|
||||
|
||||
target_compile_definitions(mbed-os
|
||||
PUBLIC
|
||||
__ASSERT_MSG
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(mbed-os
|
||||
PUBLIC
|
||||
NDEBUG
|
||||
)
|
||||
|
||||
target_link_options(mbed-os
|
||||
PUBLIC
|
||||
${link_options}
|
||||
)
|
||||
endfunction()
|
||||
|
|
Loading…
Reference in New Issue