mirror of https://github.com/ARMmbed/mbed-os.git
CMake: Set language std per target using properties
parent
a1259ecf22
commit
933b1db1be
|
@ -20,6 +20,7 @@ mbed_set_cpu_core_options(mbed-os ${MBED_TOOLCHAIN})
|
|||
|
||||
include(${MBED_ROOT}/cmake/toolchain.cmake)
|
||||
mbed_set_toolchain_options(mbed-os)
|
||||
mbed_set_language_standard(mbed-os)
|
||||
|
||||
include(${MBED_ROOT}/cmake/profile.cmake)
|
||||
mbed_set_profile_options(mbed-os ${MBED_TOOLCHAIN})
|
||||
|
@ -57,6 +58,13 @@ add_subdirectory(storage)
|
|||
add_subdirectory(targets)
|
||||
|
||||
|
||||
#
|
||||
# Configures the application
|
||||
#
|
||||
function(mbed_os_configure_app_target target)
|
||||
mbed_set_language_standard(${target})
|
||||
endfunction()
|
||||
|
||||
#
|
||||
# Specifies linker script used for linking `target`.
|
||||
#
|
||||
|
|
|
@ -8,7 +8,6 @@ function(mbed_set_profile_options target mbed_toolchain)
|
|||
if(${mbed_toolchain} STREQUAL "GCC_ARM")
|
||||
list(APPEND c_compile_options
|
||||
"-c"
|
||||
"-std=gnu11"
|
||||
"-Og"
|
||||
)
|
||||
target_compile_options(${target}
|
||||
|
@ -18,7 +17,6 @@ function(mbed_set_profile_options target mbed_toolchain)
|
|||
|
||||
list(APPEND cxx_compile_options
|
||||
"-c"
|
||||
"-std=gnu++14"
|
||||
"-fno-rtti"
|
||||
"-Wvla"
|
||||
"-Og"
|
||||
|
@ -51,7 +49,6 @@ function(mbed_set_profile_options target mbed_toolchain)
|
|||
)
|
||||
elseif(${mbed_toolchain} STREQUAL "ARM")
|
||||
list(APPEND c_compile_options
|
||||
"-std=gnu11"
|
||||
"-O1"
|
||||
)
|
||||
target_compile_options(${target}
|
||||
|
@ -60,7 +57,6 @@ function(mbed_set_profile_options target mbed_toolchain)
|
|||
)
|
||||
|
||||
list(APPEND cxx_compile_options
|
||||
"-std=gnu++14"
|
||||
"-fno-rtti"
|
||||
"-fno-c++-static-destructors"
|
||||
"-O1"
|
||||
|
|
|
@ -8,7 +8,6 @@ function(mbed_set_profile_options target mbed_toolchain)
|
|||
if(${mbed_toolchain} STREQUAL "GCC_ARM")
|
||||
list(APPEND c_compile_options
|
||||
"-c"
|
||||
"-std=gnu11"
|
||||
"-Os"
|
||||
)
|
||||
target_compile_options(${target}
|
||||
|
@ -17,7 +16,6 @@ function(mbed_set_profile_options target mbed_toolchain)
|
|||
)
|
||||
|
||||
list(APPEND cxx_compile_options
|
||||
"-std=gnu++14"
|
||||
"-fno-rtti"
|
||||
"-Wvla"
|
||||
"-Os"
|
||||
|
@ -49,7 +47,6 @@ function(mbed_set_profile_options target mbed_toolchain)
|
|||
)
|
||||
elseif(${mbed_toolchain} STREQUAL "ARM")
|
||||
list(APPEND c_compile_options
|
||||
"-std=gnu11"
|
||||
"-Os"
|
||||
)
|
||||
target_compile_options(${target}
|
||||
|
@ -58,7 +55,6 @@ function(mbed_set_profile_options target mbed_toolchain)
|
|||
)
|
||||
|
||||
list(APPEND cxx_compile_options
|
||||
"-std=gnu++14"
|
||||
"-fno-rtti"
|
||||
"-fno-c++-static-destructors"
|
||||
"-Os"
|
||||
|
|
|
@ -8,7 +8,6 @@ function(mbed_set_profile_options target mbed_toolchain)
|
|||
if(${mbed_toolchain} STREQUAL "GCC_ARM")
|
||||
list(APPEND c_compile_options
|
||||
"-c"
|
||||
"-std=gnu11"
|
||||
"-Os"
|
||||
)
|
||||
target_compile_options(${target}
|
||||
|
@ -18,7 +17,6 @@ function(mbed_set_profile_options target mbed_toolchain)
|
|||
|
||||
list(APPEND cxx_compile_options
|
||||
"-c"
|
||||
"-std=gnu++14"
|
||||
"-fno-rtti"
|
||||
"-Wvla"
|
||||
"-Os"
|
||||
|
@ -51,7 +49,6 @@ function(mbed_set_profile_options target mbed_toolchain)
|
|||
)
|
||||
elseif(${mbed_toolchain} STREQUAL "ARM")
|
||||
list(APPEND c_compile_options
|
||||
"-std=gnu11"
|
||||
"-Oz"
|
||||
)
|
||||
target_compile_options(${target}
|
||||
|
@ -60,7 +57,6 @@ function(mbed_set_profile_options target mbed_toolchain)
|
|||
)
|
||||
|
||||
list(APPEND cxx_compile_options
|
||||
"-std=gnu++14"
|
||||
"-fno-rtti"
|
||||
"-fno-c++-static-destructors"
|
||||
"-Oz"
|
||||
|
|
|
@ -41,6 +41,7 @@ elseif (MBED_CPU_CORE STREQUAL Cortex-M7FD)
|
|||
endif()
|
||||
|
||||
|
||||
|
||||
include(${MBED_ROOT}/cmake/toolchains/${MBED_TOOLCHAIN}.cmake)
|
||||
|
||||
# Compiler setup
|
||||
|
@ -52,6 +53,23 @@ set(CMAKE_CXX_COMPILER_WORKS TRUE)
|
|||
# Project setup
|
||||
enable_language(C CXX ASM)
|
||||
|
||||
# Set the language standard to use per target
|
||||
function(mbed_set_language_standard target)
|
||||
set_target_properties(${target}
|
||||
PROPERTIES
|
||||
C_STANDARD 11
|
||||
C_STANDARD_REQUIRED YES
|
||||
C_EXTENSIONS YES
|
||||
)
|
||||
|
||||
set_target_properties(${target}
|
||||
PROPERTIES
|
||||
CXX_STANDARD 14
|
||||
CXX_STANDARD_REQUIRED YES
|
||||
CXX_EXTENSIONS YES
|
||||
)
|
||||
endfunction()
|
||||
|
||||
# Clear toolchains options for all languages as Mbed OS uses
|
||||
# different initialisation options (such as for optimization and debug symbols)
|
||||
set(CMAKE_C_FLAGS_DEBUG "" CACHE STRING "" FORCE)
|
||||
|
|
Loading…
Reference in New Issue