@@ -14,34 +14,52 @@ set(CMAKE_ASM_FLAGS " -mthumb -mcpu=cortex-m0 -mfloat-abi=soft -mabi=aapcs -x as
1414set (CMAKE_EXE_LINKER_FLAGS " -Wl,--gc-sections -Wl,--no-wchar-size-warning -Wl,--print-memory-usage -mthumb -mcpu=cortex-m0 -mfloat-abi=soft -mabi=aapcs -nostartfiles " CACHE INTERNAL "executable linker flags" )
1515
1616
17- function (NF_SET_COMPILER_OPTIONS TARGET )
17+ # TARGET parameter to set the target that's setting them for
18+ # optional EXTRA_COMPILE_OPTIONS with compile options to be added
19+ macro (nf_set_compile_options)
20+
21+ # parse arguments
22+ cmake_parse_arguments (NFSCO "" "TARGET" "EXTRA_COMPILE_OPTIONS" ${ARGN} )
23+
24+ if (NOT NFSCO_TARGET OR "${NFSCO_TARGET} " STREQUAL "" )
25+ message (FATAL_ERROR "Need to set TARGET argument when calling nf_set_compile_options()" )
26+ endif ()
1827
1928 # include any extra options coming from any extra args?
20- target_compile_options (${TARGET } PUBLIC ${ARGN } -mthumb -mcpu=cortex-m0 -mabi=aapcs -nostdlib -Wall -Wextra -Werror -Wundef -fshort-wchar -fno-builtin -fno-common -mno-long-calls -fno-exceptions -fcheck-new )
29+ target_compile_options (${NFSCO_TARGET } PUBLIC ${NFSCO_EXTRA_COMPILE_OPTIONS } -mthumb -mcpu=cortex-m0 -mabi=aapcs -nostdlib -Wall -Wextra -Werror -Wundef -Wshadow -Wimplicit-fallthrough -fshort-wchar -fno-builtin -fno-common -mno-long-calls -fno-exceptions -fcheck-new )
2130
2231 # this series doesn't have FPU
23- target_compile_definitions (${TARGET } PUBLIC -DCORTEX_USE_FPU=FALSE -DUSE_FPU=TRUE )
32+ target_compile_definitions (${NFSCO_TARGET } PUBLIC -DPLATFORM_ARM -DCORTEX_USE_FPU=FALSE -DUSE_FPU=TRUE )
2433
25- endfunction ()
34+ endmacro ()
2635
2736
28- function (NF_SET_LINKER_OPTIONS TARGET )
37+ # TARGET parameter to set the target that's setting them for
38+ # optional EXTRA_LINK_FLAGS with link flags to be added
39+ macro (nf_set_linker_options)
2940
30- # request specs from newlib nano
31- set_property (TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " --specs=nano.specs " )
41+ # parse arguments
42+ cmake_parse_arguments (NFSLO "" "TARGET;EXTRA_LINK_FLAGS" "" ${ARGN} )
43+
44+ if (NOT NFSLO_TARGET OR "${NFSLO_TARGET} " STREQUAL "" )
45+ message (FATAL_ERROR "Need to set TARGET argument when calling nf_set_linker_options()" )
46+ endif ()
3247
33- # set extra linker flags
34- set_property (TARGET ${TARGET } APPEND_STRING PROPERTY LINK_FLAGS " ${ARGN} " )
48+ # request specs from newlib nano
49+ set_property (TARGET ${NFSLO_TARGET } APPEND_STRING PROPERTY LINK_FLAGS " --specs=nano.specs " )
3550
3651 # set optimization linker flags for RELEASE and MinSizeRel
3752 if (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel" )
38- set_property (TARGET ${TARGET } APPEND_STRING PROPERTY LINK_FLAGS " -flto -Os -fstrict-aliasing -fomit-frame-pointer -fno-unroll-loops -frounding-math -fsignaling-nans -ffloat-store -fno-math-errno -ftree-vectorize -fno-default-inline -finline-functions-called-once -fno-defer-pop " )
53+ set_property (TARGET ${NFSLO_TARGET } APPEND_STRING PROPERTY LINK_FLAGS " -flto -Os -fstrict-aliasing -fomit-frame-pointer -fno-unroll-loops -frounding-math -fsignaling-nans -ffloat-store -fno-math-errno -ftree-vectorize -fno-default-inline -finline-functions-called-once -fno-defer-pop " )
3954 endif ()
4055
56+ # include libraries in build
57+ nf_include_libraries_in_build(${NFSLO_TARGET} )
58+
59+ # set extra linker flags
60+ set_property (TARGET ${NFSLO_TARGET} APPEND_STRING PROPERTY LINK_FLAGS " ${NFSLO_EXTRA_LINK_FLAGS} " )
61+
4162 # set optimization flags
42- nf_set_optimization_options(${TARGET} )
43-
44- # set link map
45- nf_set_link_map(${TARGET} )
63+ nf_set_optimization_options(${NFSLO_TARGET} )
4664
47- endfunction ()
65+ endmacro ()
0 commit comments