cmake: Refactored EXTRA_FLAGS code into a dedicated script
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
This commit is contained in:
parent
7bc28cf388
commit
9f59045546
|
@ -180,34 +180,7 @@ endif()
|
|||
|
||||
# Allow the user to inject options when calling cmake, e.g.
|
||||
# 'cmake -DEXTRA_CFLAGS="-Werror -Wno-deprecated-declarations" ..'
|
||||
|
||||
separate_arguments(EXTRA_CPPFLAGS_AS_LIST UNIX_COMMAND ${EXTRA_CPPFLAGS})
|
||||
separate_arguments(EXTRA_LD_FLAGS_AS_LIST UNIX_COMMAND ${EXTRA_LD_FLAGS})
|
||||
separate_arguments(EXTRA_CFLAGS_AS_LIST UNIX_COMMAND ${EXTRA_CFLAGS})
|
||||
separate_arguments(EXTRA_CXXFLAGS_AS_LIST UNIX_COMMAND ${EXTRA_CXXFLAGS})
|
||||
separate_arguments(EXTRA_AFLAGS_AS_LIST UNIX_COMMAND ${EXTRA_AFLAGS})
|
||||
|
||||
if(EXTRA_CPPFLAGS)
|
||||
zephyr_compile_definitions(${EXTRA_CPPFLAGS_AS_LIST})
|
||||
endif()
|
||||
if(EXTRA_LDFLAGS)
|
||||
zephyr_link_libraries(${EXTRA_LDFLAGS_AS_LIST})
|
||||
endif()
|
||||
if(EXTRA_CFLAGS)
|
||||
foreach(F ${EXTRA_CFLAGS_AS_LIST})
|
||||
zephyr_compile_options($<$<COMPILE_LANGUAGE:C>:${F}>)
|
||||
endforeach()
|
||||
endif()
|
||||
if(EXTRA_CXXFLAGS)
|
||||
foreach(F ${EXTRA_CXXFLAGS_AS_LIST})
|
||||
zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:${F}>)
|
||||
endforeach()
|
||||
endif()
|
||||
if(EXTRA_AFLAGS)
|
||||
foreach(F ${EXTRA_AFLAGS_AS_LIST})
|
||||
zephyr_compile_options($<$<COMPILE_LANGUAGE:ASM>:${F}>)
|
||||
endforeach()
|
||||
endif()
|
||||
include(cmake/extra_flags.cmake)
|
||||
|
||||
if(CONFIG_READABLE_ASM)
|
||||
zephyr_cc_option(-fno-reorder-blocks)
|
||||
|
|
28
cmake/extra_flags.cmake
Normal file
28
cmake/extra_flags.cmake
Normal file
|
@ -0,0 +1,28 @@
|
|||
separate_arguments(EXTRA_CPPFLAGS_AS_LIST UNIX_COMMAND ${EXTRA_CPPFLAGS})
|
||||
separate_arguments(EXTRA_LD_FLAGS_AS_LIST UNIX_COMMAND ${EXTRA_LD_FLAGS})
|
||||
separate_arguments(EXTRA_CFLAGS_AS_LIST UNIX_COMMAND ${EXTRA_CFLAGS})
|
||||
separate_arguments(EXTRA_CXXFLAGS_AS_LIST UNIX_COMMAND ${EXTRA_CXXFLAGS})
|
||||
separate_arguments(EXTRA_AFLAGS_AS_LIST UNIX_COMMAND ${EXTRA_AFLAGS})
|
||||
|
||||
if(EXTRA_CPPFLAGS)
|
||||
zephyr_compile_definitions(${EXTRA_CPPFLAGS_AS_LIST})
|
||||
endif()
|
||||
if(EXTRA_LDFLAGS)
|
||||
zephyr_link_libraries(${EXTRA_LDFLAGS_AS_LIST})
|
||||
endif()
|
||||
if(EXTRA_CFLAGS)
|
||||
foreach(F ${EXTRA_CFLAGS_AS_LIST})
|
||||
zephyr_compile_options($<$<COMPILE_LANGUAGE:C>:${F}>)
|
||||
endforeach()
|
||||
endif()
|
||||
if(EXTRA_CXXFLAGS)
|
||||
foreach(F ${EXTRA_CXXFLAGS_AS_LIST})
|
||||
zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:${F}>)
|
||||
endforeach()
|
||||
endif()
|
||||
if(EXTRA_AFLAGS)
|
||||
foreach(F ${EXTRA_AFLAGS_AS_LIST})
|
||||
zephyr_compile_options($<$<COMPILE_LANGUAGE:ASM>:${F}>)
|
||||
endforeach()
|
||||
endif()
|
||||
|
Loading…
Reference in a new issue