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
20 changes: 10 additions & 10 deletions tools/cmake/profiles/debug.cmake
Original file line number Diff line number Diff line change
@@ -6,33 +6,33 @@ function(mbed_set_profile_options target mbed_toolchain)
set(profile_link_options "")

if(${mbed_toolchain} STREQUAL "GCC_ARM")
list(APPEND c_compile_options
list(APPEND profile_c_compile_options
"-c"
"-Og"
)
target_compile_options(${target}
INTERFACE
$<$<COMPILE_LANGUAGE:C>:${c_compile_options}>
$<$<COMPILE_LANGUAGE:C>:${profile_c_compile_options}>
)

list(APPEND cxx_compile_options
list(APPEND profile_cxx_compile_options
"-c"
"-fno-rtti"
"-Wvla"
"-Og"
)
target_compile_options(${target}
INTERFACE
$<$<COMPILE_LANGUAGE:CXX>:${cxx_compile_options}>
$<$<COMPILE_LANGUAGE:CXX>:${profile_cxx_compile_options}>
)

list(APPEND asm_compile_options
list(APPEND profile_asm_compile_options
"-c"
"-x" "assembler-with-cpp"
)
target_compile_options(${target}
INTERFACE
$<$<COMPILE_LANGUAGE:ASM>:${asm_compile_options}>
$<$<COMPILE_LANGUAGE:ASM>:${profile_asm_compile_options}>
)

list(APPEND profile_link_options
@@ -48,22 +48,22 @@ function(mbed_set_profile_options target mbed_toolchain)
"-Wl,-n"
)
elseif(${mbed_toolchain} STREQUAL "ARM")
list(APPEND c_compile_options
list(APPEND profile_c_compile_options
"-O1"
)
target_compile_options(${target}
INTERFACE
$<$<COMPILE_LANGUAGE:C>:${c_compile_options}>
$<$<COMPILE_LANGUAGE:C>:${profile_c_compile_options}>
)

list(APPEND cxx_compile_options
list(APPEND profile_cxx_compile_options
"-fno-rtti"
"-fno-c++-static-destructors"
"-O1"
)
target_compile_options(${target}
INTERFACE
$<$<COMPILE_LANGUAGE:CXX>:${cxx_compile_options}>
$<$<COMPILE_LANGUAGE:CXX>:${profile_cxx_compile_options}>
)

list(APPEND link_options
20 changes: 10 additions & 10 deletions tools/cmake/profiles/develop.cmake
Original file line number Diff line number Diff line change
@@ -6,31 +6,31 @@ function(mbed_set_profile_options target mbed_toolchain)
set(profile_link_options "")

if(${mbed_toolchain} STREQUAL "GCC_ARM")
list(APPEND c_compile_options
list(APPEND profile_c_compile_options
"-c"
"-Os"
)
target_compile_options(${target}
INTERFACE
$<$<COMPILE_LANGUAGE:C>:${c_compile_options}>
$<$<COMPILE_LANGUAGE:C>:${profile_c_compile_options}>
)

list(APPEND cxx_compile_options
list(APPEND profile_cxx_compile_options
"-fno-rtti"
"-Wvla"
"-Os"
)
target_compile_options(${target}
INTERFACE
$<$<COMPILE_LANGUAGE:CXX>:${cxx_compile_options}>
$<$<COMPILE_LANGUAGE:CXX>:${profile_cxx_compile_options}>
)

list(APPEND asm_compile_options
list(APPEND profile_asm_compile_options
"-x" "assembler-with-cpp"
)
target_compile_options(${target}
INTERFACE
$<$<COMPILE_LANGUAGE:ASM>:${asm_compile_options}>
$<$<COMPILE_LANGUAGE:ASM>:${profile_asm_compile_options}>
)

list(APPEND profile_link_options
@@ -46,22 +46,22 @@ function(mbed_set_profile_options target mbed_toolchain)
"-Wl,-n"
)
elseif(${mbed_toolchain} STREQUAL "ARM")
list(APPEND c_compile_options
list(APPEND profile_c_compile_options
"-Os"
)
target_compile_options(${target}
INTERFACE
$<$<COMPILE_LANGUAGE:C>:${c_compile_options}>
$<$<COMPILE_LANGUAGE:C>:${profile_c_compile_options}>
)

list(APPEND cxx_compile_options
list(APPEND profile_cxx_compile_options
"-fno-rtti"
"-fno-c++-static-destructors"
"-Os"
)
target_compile_options(${target}
INTERFACE
$<$<COMPILE_LANGUAGE:CXX>:${cxx_compile_options}>
$<$<COMPILE_LANGUAGE:CXX>:${profile_cxx_compile_options}>
)

list(APPEND profile_link_options
20 changes: 10 additions & 10 deletions tools/cmake/profiles/release.cmake
Original file line number Diff line number Diff line change
@@ -6,33 +6,33 @@ function(mbed_set_profile_options target mbed_toolchain)
set(profile_link_options "")

if(${mbed_toolchain} STREQUAL "GCC_ARM")
list(APPEND c_compile_options
list(APPEND profile_c_compile_options
"-c"
"-Os"
)
target_compile_options(${target}
INTERFACE
$<$<COMPILE_LANGUAGE:C>:${c_compile_options}>
$<$<COMPILE_LANGUAGE:C>:${profile_c_compile_options}>
)

list(APPEND cxx_compile_options
list(APPEND profile_cxx_compile_options
"-c"
"-fno-rtti"
"-Wvla"
"-Os"
)
target_compile_options(${target}
INTERFACE
$<$<COMPILE_LANGUAGE:CXX>:${cxx_compile_options}>
$<$<COMPILE_LANGUAGE:CXX>:${profile_cxx_compile_options}>
)

list(APPEND asm_compile_options
list(APPEND profile_asm_compile_options
"-c"
"-x" "assembler-with-cpp"
)
target_compile_options(${target}
INTERFACE
$<$<COMPILE_LANGUAGE:ASM>:${asm_compile_options}>
$<$<COMPILE_LANGUAGE:ASM>:${profile_asm_compile_options}>
)

list(APPEND profile_link_options
@@ -48,22 +48,22 @@ function(mbed_set_profile_options target mbed_toolchain)
"-Wl,-n"
)
elseif(${mbed_toolchain} STREQUAL "ARM")
list(APPEND c_compile_options
list(APPEND profile_c_compile_options
"-Oz"
)
target_compile_options(${target}
INTERFACE
$<$<COMPILE_LANGUAGE:C>:${c_compile_options}>
$<$<COMPILE_LANGUAGE:C>:${profile_c_compile_options}>
)

list(APPEND cxx_compile_options
list(APPEND profile_cxx_compile_options
"-fno-rtti"
"-fno-c++-static-destructors"
"-Oz"
)
target_compile_options(${target}
INTERFACE
$<$<COMPILE_LANGUAGE:CXX>:${cxx_compile_options}>
$<$<COMPILE_LANGUAGE:CXX>:${profile_cxx_compile_options}>
)

list(APPEND profile_link_options