Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
87304bd
Fix target_compile_definitions
josesimoes Aug 18, 2021
3a565f0
Configure file target_os is now placed in a good known location
josesimoes Aug 18, 2021
57034cc
Rename include directory to use correct case
josesimoes Aug 18, 2021
cb06a76
Configure file target_board is now placed in a good known location
josesimoes Aug 18, 2021
b78eef9
Configure file target_common is now placed in a good known location
josesimoes Aug 18, 2021
f7c6dc7
Fix target_board generation for TI CC3220SF
josesimoes Aug 18, 2021
1709322
Fixed destination location for some template generated files
josesimoes Aug 18, 2021
1c5da2e
Rename of TI-SimpleLink
josesimoes Aug 18, 2021
a1c448d
Rename RTOS in main CMake to match case
josesimoes Aug 18, 2021
1cca734
Fix mirroring of HAL_USE_RTC_OPTION to NXP HAL
josesimoes Aug 18, 2021
6b318c0
Network components now build as a library
josesimoes Aug 19, 2021
312b220
Global rename of macros and functions
josesimoes Aug 19, 2021
9c00e71
Add missing include for ChibiOS network build
josesimoes Aug 19, 2021
7e9e757
Rework nanoHALCore module to be a library
josesimoes Aug 19, 2021
2d21d75
Add common dependencies macro
josesimoes Aug 19, 2021
10b6d09
Fix build for ESP32
josesimoes Aug 19, 2021
967febb
Adjust block storage size release build of ST_NUCLEO64_F091RC
josesimoes Aug 19, 2021
2871a2e
Fix define check
josesimoes Aug 19, 2021
77d7cbc
Rework nf_set_compiler_definitions
josesimoes Aug 20, 2021
436828e
Rename nf_set_compile_options for coherence
josesimoes Aug 20, 2021
a1476a1
Rework CoreCLR to become a library
josesimoes Aug 20, 2021
ff5838b
Refactor nf_set_linker_options
josesimoes Aug 20, 2021
ae48e81
Fix NF_HALCore build
josesimoes Aug 20, 2021
ef2b78f
Refactor nf_set_link_map
josesimoes Aug 20, 2021
42e5450
Fix build on some targets
josesimoes Aug 20, 2021
0cb3e56
Add nf_include_libraries_in_build macro
josesimoes Aug 20, 2021
ddf7d9f
HALCore doesn't build as a library anymore
josesimoes Aug 20, 2021
8c5ea31
Fix compiler error with duplicated names
josesimoes Aug 20, 2021
db59f47
Several fixes in CMakes
josesimoes Aug 21, 2021
d4b8d87
Move language definition to main CMake
josesimoes Aug 21, 2021
5228528
Improve check of build options
josesimoes Aug 21, 2021
430a142
Improve vars and globals cleaning
josesimoes Aug 21, 2021
5fa25b2
Fix inclusion of gcc library
josesimoes Aug 21, 2021
92c5bcb
Fix include dirs for ChibiOS build
josesimoes Aug 21, 2021
27c81d0
Fix managed heap size of ST_NUCLEO64_F091RC
josesimoes Aug 21, 2021
e00b2c8
Add nf_setup_target_build
josesimoes Aug 21, 2021
047c367
Miscellaneous build fixes
josesimoes Aug 23, 2021
9cee633
Native assemblies are now added to the build as a library
josesimoes Aug 23, 2021
c110bc9
Fix ChibiOS build
josesimoes Aug 23, 2021
893b6ed
Fix NF_Assemblies build for TI SimpleLink
josesimoes Aug 23, 2021
57ccd92
Rework nf_set_compile_options
josesimoes Aug 23, 2021
f2904f0
Rework all macros to use individual prefix
josesimoes Aug 23, 2021
556662e
Refactor all targets to use new macro nf_setup_target_build
josesimoes Aug 23, 2021
654f7cf
Fix inclusion of NF_HALCore
josesimoes Aug 24, 2021
a92aafe
NF_Debugger and Wire Protocol are now a libraries
josesimoes Aug 24, 2021
b4cf7e1
Add quiet arg to find package to decrease build verbosity
josesimoes Aug 24, 2021
2ab6a20
Remove TI CC3220 from ChibiOS nano overlay
josesimoes Aug 24, 2021
7bf6841
Refactor header include guards
josesimoes Aug 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .vscode/cmake-variants.TEMPLATE.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"USE_RNG": "<ON-default-for-using-hardware-true-random-generator-unit>",
"DP_FLOATINGPOINT": "<OFF-default-ON-for-adding-support-for-double-precision-floating-point>",
"SUPPORT_ANY_BASE_CONVERSION": "<OFF-default-ON-for-adding-support-for-conversion-strings-to-values-on-any-base>",
"RTOS": "<one-of-valid-rtos-options-CHIBIOS-FREERTOS-FREERTOS_ESP32-TI_SIMPLELINK>",
"RTOS": "<one-of-valid-rtos-options-ChibiOS-FreeRTOS-FreeRTOS_ESP32-TI_SIMPLELINK>",
"RTOS_SOURCE_FOLDER": "<path-to-RTOS-source-folder-if-supported-mind-the-forward-slash>",
"CHIBIOS_CONTRIB_REQUIRED": "OFF-default-ON-to-include_ChibiOS-Contrib-repository-in-the-build",
"CHIBIOS_CONTRIB_SOURCE": "<path-to-local-ChibiOS-contrib-source-mind-the-forward-slash>",
Expand All @@ -50,8 +50,8 @@
"CMSIS_VERSION": "<valid-cmsis-version-if-empty-use-default-set-cmake>",
"STM32_CUBE_PACKAGE_REQUIRED": "<OFF-default-ON-to-include_STM-cube-package-in-the-build>",
"STM32_CUBE_PACKAGE_SOURCE": "<path-to-stm32-cubemx-package-mind-the-forward-slash>",
"TI_SL_CC32xx_SDK_SOURCE": "<path-to-local-TI-SimpleLink-CC32xx-SDK-source-mind-the-forward-slash>",
"TI_SL_CC13x2_26x2_SDK_SOURCE": "<path-to-local-TI-SimpleLink-CC13x2_26x2-SDK-source-mind-the-forward-slash>",
"TI_SL_CC32xx_SDK_SOURCE": "<path-to-local-TI_SimpleLink-CC32xx-SDK-source-mind-the-forward-slash>",
"TI_SL_CC13x2_26x2_SDK_SOURCE": "<path-to-local-TI_SimpleLink-CC13x2_26x2-SDK-source-mind-the-forward-slash>",
"TI_XDCTOOLS_SOURCE": "<path-to-local-TI-XDC-Tools-source-mind-the-forward-slash>",
"TI_SYSCONFIG_SOURCE": "<path-to-local-TI-SYSCONFIG-Tool-source-mind-the-forward-slash>",
"RADIO_FREQUENCY": "<radio-frequency-for-target-with-configurable-radio-valid-values-868-915>",
Expand Down
6 changes: 3 additions & 3 deletions CMake/ChibiOS_target_os.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

#include <chversion.h>

#ifndef _TARGET_OS_H_
#define _TARGET_OS_H_ 1
#ifndef TARGET_OS_H
#define TARGET_OS_H

#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)
Expand All @@ -31,4 +31,4 @@
#define NANOCLR_SYSTEM_COLLECTIONS @TARGET_SYSTEM_COLLECTIONS@
#define TARGET_HAS_NANOBOOTER @TARGET_HAS_NANOBOOTER@

#endif /* _TARGET_OS_H_ */
#endif // TARGET_OS_H
6 changes: 3 additions & 3 deletions CMake/ESP32_target_os.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// Any changes you make here will be overwritten when it's generated again. //
//////////////////////////////////////////////////////////////////////////////

#ifndef _TARGET_OS_H_
#define _TARGET_OS_H_ 1
#ifndef TARGET_OS_H
#define TARGET_OS_H

#define VERSION_MAJOR @nanoFramework_VERSION_MAJOR@U
#define VERSION_MINOR @nanoFramework_VERSION_MINOR@U
Expand All @@ -27,4 +27,4 @@
#define TARGET_HAS_NANOBOOTER FALSE
#cmakedefine TARGET_SERIAL_BAUDRATE @TARGET_SERIAL_BAUDRATE@

#endif /* _TARGET_OS_H_ */
#endif // TARGET_OS_H
6 changes: 3 additions & 3 deletions CMake/FreeRTOS_target_os.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// Any changes you make here will be overwritten when it's generated again. //
//////////////////////////////////////////////////////////////////////////////

#ifndef _TARGET_OS_H_
#define _TARGET_OS_H_ 1
#ifndef TARGET_OS_H
#define TARGET_OS_H

#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)
Expand All @@ -29,4 +29,4 @@
#define NANOCLR_SYSTEM_COLLECTIONS @TARGET_SYSTEM_COLLECTIONS@
#define TARGET_HAS_NANOBOOTER @TARGET_HAS_NANOBOOTER@

#endif /* _TARGET_OS_H_ */
#endif // TARGET_OS_H
48 changes: 33 additions & 15 deletions CMake/Modules/CHIBIOS_STM32F0xx_GCC_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,52 @@ set(CMAKE_ASM_FLAGS " -mthumb -mcpu=cortex-m0 -mfloat-abi=soft -mabi=aapcs -x as
set(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")


function(NF_SET_COMPILER_OPTIONS TARGET)
# TARGET parameter to set the target that's setting them for
# optional EXTRA_COMPILE_OPTIONS with compile options to be added
macro(nf_set_compile_options)

# parse arguments
cmake_parse_arguments(NFSCO "" "TARGET" "EXTRA_COMPILE_OPTIONS" ${ARGN})

if(NOT NFSCO_TARGET OR "${NFSCO_TARGET}" STREQUAL "")
message(FATAL_ERROR "Need to set TARGET argument when calling nf_set_compile_options()")
endif()

# include any extra options coming from any extra args?
target_compile_options(${TARGET} PUBLIC ${ARGN} -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 )
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 )

# this series doesn't have FPU
target_compile_definitions(${TARGET} PUBLIC -DCORTEX_USE_FPU=FALSE -DUSE_FPU=TRUE)
target_compile_definitions(${NFSCO_TARGET} PUBLIC -DPLATFORM_ARM -DCORTEX_USE_FPU=FALSE -DUSE_FPU=TRUE)

endfunction()
endmacro()


function(NF_SET_LINKER_OPTIONS TARGET)
# TARGET parameter to set the target that's setting them for
# optional EXTRA_LINK_FLAGS with link flags to be added
macro(nf_set_linker_options)

# request specs from newlib nano
set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " --specs=nano.specs ")
# parse arguments
cmake_parse_arguments(NFSLO "" "TARGET;EXTRA_LINK_FLAGS" "" ${ARGN})

if(NOT NFSLO_TARGET OR "${NFSLO_TARGET}" STREQUAL "")
message(FATAL_ERROR "Need to set TARGET argument when calling nf_set_linker_options()")
endif()

# set extra linker flags
set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " ${ARGN}")
# request specs from newlib nano
set_property(TARGET ${NFSLO_TARGET} APPEND_STRING PROPERTY LINK_FLAGS " --specs=nano.specs ")

# set optimization linker flags for RELEASE and MinSizeRel
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
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 ")
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 ")
endif()

# include libraries in build
nf_include_libraries_in_build(${NFSLO_TARGET})

# set extra linker flags
set_property(TARGET ${NFSLO_TARGET} APPEND_STRING PROPERTY LINK_FLAGS " ${NFSLO_EXTRA_LINK_FLAGS} ")

# set optimization flags
nf_set_optimization_options(${TARGET})

# set link map
nf_set_link_map(${TARGET})
nf_set_optimization_options(${NFSLO_TARGET})

endfunction()
endmacro()
51 changes: 35 additions & 16 deletions CMake/Modules/CHIBIOS_STM32F4xx_GCC_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,53 @@ set(CMAKE_ASM_FLAGS " -mthumb -mcpu=cortex-m4 -x assembler-with-cpp" CACHE INTER
set(CMAKE_EXE_LINKER_FLAGS " -Wl,--gc-sections -Wl,--no-wchar-size-warning -Wl,--print-memory-usage -mthumb -mcpu=cortex-m4 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mabi=aapcs -nostartfiles " CACHE INTERNAL "executable linker flags")


function(NF_SET_COMPILER_OPTIONS TARGET)
# TARGET parameter to set the target that's setting them for
# optional EXTRA_COMPILE_OPTIONS with compile options to be added
macro(nf_set_compile_options)

# parse arguments
cmake_parse_arguments(NFSCO "" "TARGET" "EXTRA_COMPILE_OPTIONS" ${ARGN})

if(NOT NFSCO_TARGET OR "${NFSCO_TARGET}" STREQUAL "")
message(FATAL_ERROR "Need to set TARGET argument when calling nf_set_compile_options()")
endif()


# include any extra options coming from any extra args?
target_compile_options(${TARGET} PUBLIC ${ARGN} -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mabi=aapcs -nostdlib -Wall -Wextra -Werror -Wundef -Wshadow -Wimplicit-fallthrough -fshort-wchar -fno-builtin -fno-common -mno-long-calls -fno-exceptions -fcheck-new )
target_compile_options(${NFSCO_TARGET} PUBLIC ${__EXTRA_COMPILE_OPTIONS} -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mabi=aapcs -nostdlib -Wall -Wextra -Werror -Wundef -Wshadow -Wimplicit-fallthrough -fshort-wchar -fno-builtin -fno-common -mno-long-calls -fno-exceptions -fcheck-new )

# this series has FPU
target_compile_definitions(${TARGET} PUBLIC -DCORTEX_USE_FPU=TRUE -DUSE_FPU=TRUE)
target_compile_definitions(${NFSCO_TARGET} PUBLIC -DPLATFORM_ARM -DCORTEX_USE_FPU=TRUE -DUSE_FPU=TRUE)

endfunction()
endmacro()


function(NF_SET_LINKER_OPTIONS TARGET)
# TARGET parameter to set the target that's setting them for
# optional EXTRA_LINK_FLAGS with link flags to be added
macro(nf_set_linker_options)

# request specs from newlib nano
set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " --specs=nano.specs ")
# parse arguments
cmake_parse_arguments(NFSLO "" "TARGET;EXTRA_LINK_FLAGS" "" ${ARGN})

if(NOT NFSLO_TARGET OR "${NFSLO_TARGET}" STREQUAL "")
message(FATAL_ERROR "Need to set TARGET argument when calling nf_set_linker_options()")
endif()

# set extra linker flags
set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " ${ARGN}")
# request specs from newlib nano
set_property(TARGET ${NFSLO_TARGET} APPEND_STRING PROPERTY LINK_FLAGS " --specs=nano.specs ")

# set optimization linker flags for RELEASE and MinSizeRel
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
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 ")
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 ")
endif()

# include libraries in build
nf_include_libraries_in_build(${NFSLO_TARGET})

# set extra linker flags
set_property(TARGET ${NFSLO_TARGET} APPEND_STRING PROPERTY LINK_FLAGS " ${__EXTRA_LINK_FLAGS} ")

# set optimization flags
nf_set_optimization_options(${TARGET})

# set link map
nf_set_link_map(${TARGET})

endfunction()
nf_set_optimization_options(${NFSLO_TARGET})

endmacro()
47 changes: 32 additions & 15 deletions CMake/Modules/CHIBIOS_STM32F7xx_GCC_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,52 @@ set(CMAKE_ASM_FLAGS " -mthumb -mcpu=cortex-m7 -x assembler-with-cpp" CACHE INTER
set(CMAKE_EXE_LINKER_FLAGS " -Wl,--gc-sections -Wl,--no-wchar-size-warning -Wl,--print-memory-usage -mthumb -mcpu=cortex-m7 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mabi=aapcs -nostartfiles " CACHE INTERNAL "executable linker flags")


function(NF_SET_COMPILER_OPTIONS TARGET)
# TARGET parameter to set the target that's setting them for
# optional EXTRA_COMPILE_OPTIONS with compile options to be added
macro(nf_set_compile_options)

# parse arguments
cmake_parse_arguments(NFSCO "" "TARGET" "EXTRA_COMPILE_OPTIONS" ${ARGN})

if(NOT NFSCO_TARGET OR "${NFSCO_TARGET}" STREQUAL "")
message(FATAL_ERROR "Need to set TARGET argument when calling nf_set_compile_options()")
endif()

# include any extra options coming from any extra args?
# STMF7 cores have SP and DP, the default is SP. DP can be set if developer realy needs that.
target_compile_options(${TARGET} PUBLIC ${ARGN} -mthumb -mcpu=cortex-m7 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mabi=aapcs -nostdlib -Wall -Wextra -Werror -Wundef -Wshadow -Wimplicit-fallthrough -fshort-wchar -fno-builtin -fno-common -mno-long-calls -fno-exceptions -fcheck-new )
target_compile_options(${NFSCO_TARGET} PUBLIC ${__EXTRA_COMPILE_OPTIONS} -mthumb -mcpu=cortex-m7 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mabi=aapcs -nostdlib -Wall -Wextra -Werror -Wundef -Wshadow -Wimplicit-fallthrough -fshort-wchar -fno-builtin -fno-common -mno-long-calls -fno-exceptions -fcheck-new )

# this series has FPU
target_compile_definitions(${TARGET} PUBLIC -DCORTEX_USE_FPU=TRUE -DUSE_FPU=TRUE)
target_compile_definitions(${NFSCO_TARGET} PUBLIC -DPLATFORM_ARM -DCORTEX_USE_FPU=TRUE -DUSE_FPU=TRUE)

endfunction()
endmacro()

# TARGET parameter to set the target that's setting them for
# optional EXTRA_LINK_FLAGS with link flags to be added
macro(nf_set_linker_options)

function(NF_SET_LINKER_OPTIONS TARGET)
# parse arguments
cmake_parse_arguments(NFSLO "" "TARGET;EXTRA_LINK_FLAGS" "" ${ARGN})

# request specs from newlib nano
set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " --specs=nano.specs ")
if(NOT NFSLO_TARGET OR "${NFSLO_TARGET}" STREQUAL "")
message(FATAL_ERROR "Need to set TARGET argument when calling nf_set_linker_options()")
endif()

# set extra linker flags
set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " ${ARGN}")
# request specs from newlib nano
set_property(TARGET ${NFSLO_TARGET} APPEND_STRING PROPERTY LINK_FLAGS " --specs=nano.specs ")

# set optimization linker flags for RELEASE and MinSizeRel
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
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 ")
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 ")
endif()

# include libraries in build
nf_include_libraries_in_build(${NFSLO_TARGET})

# set extra linker flags
set_property(TARGET ${NFSLO_TARGET} APPEND_STRING PROPERTY LINK_FLAGS " ${__EXTRA_LINK_FLAGS} ")

# set optimization flags
nf_set_optimization_options(${TARGET})

# set link map
nf_set_link_map(${TARGET})
nf_set_optimization_options(${NFSLO_TARGET})

endfunction()
endmacro()
49 changes: 34 additions & 15 deletions CMake/Modules/CHIBIOS_STM32H7xx_GCC_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,54 @@ set(CMAKE_ASM_FLAGS " -mthumb -mcpu=cortex-m7 -x assembler-with-cpp" CACHE INTER
set(CMAKE_EXE_LINKER_FLAGS " -Wl,--gc-sections -Wl,--no-wchar-size-warning -Wl,--print-memory-usage -mthumb -mcpu=cortex-m7 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mabi=aapcs -nostartfiles " CACHE INTERNAL "executable linker flags")


function(NF_SET_COMPILER_OPTIONS TARGET)
# TARGET parameter to set the target that's setting them for
# optional EXTRA_COMPILE_OPTIONS with compile options to be added
macro(nf_set_compile_options)

# parse arguments
cmake_parse_arguments(NFSCO "" "TARGET" "EXTRA_COMPILE_OPTIONS" ${ARGN})

if(NOT NFSCO_TARGET OR "${NFSCO_TARGET}" STREQUAL "")
message(FATAL_ERROR "Need to set TARGET argument when calling nf_set_compile_options()")
endif()


# include any extra options coming from any extra args?
# STMF7 cores have SP and DP, the default is SP. DP can be set if developer realy needs that.
target_compile_options(${TARGET} PUBLIC ${ARGN} -mthumb -mcpu=cortex-m7 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mabi=aapcs -nostdlib -Wall -Wextra -Werror -Wundef -Wshadow -Wimplicit-fallthrough -fshort-wchar -fno-builtin -fno-common -mno-long-calls -fno-exceptions -fcheck-new )
target_compile_options(${NFSCO_TARGET} PUBLIC ${__EXTRA_COMPILE_OPTIONS} -mthumb -mcpu=cortex-m7 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mabi=aapcs -nostdlib -Wall -Wextra -Werror -Wundef -Wshadow -Wimplicit-fallthrough -fshort-wchar -fno-builtin -fno-common -mno-long-calls -fno-exceptions -fcheck-new )

# this series has FPU
target_compile_definitions(${TARGET} PUBLIC -DCORTEX_USE_FPU=TRUE -DUSE_FPU=TRUE)
target_compile_definitions(${NFSCO_TARGET} PUBLIC -DPLATFORM_ARM -DCORTEX_USE_FPU=TRUE -DUSE_FPU=TRUE)

endfunction()
endmacro()


function(NF_SET_LINKER_OPTIONS TARGET)
# TARGET parameter to set the target that's setting them for
# optional EXTRA_LINK_FLAGS with link flags to be added
macro(nf_set_linker_options)

# request specs from newlib nano
set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " --specs=nano.specs ")
# parse arguments
cmake_parse_arguments(NFSLO "" "TARGET;EXTRA_LINK_FLAGS" "" ${ARGN})

if(NOT NFSLO_TARGET OR "${NFSLO_TARGET}" STREQUAL "")
message(FATAL_ERROR "Need to set TARGET argument when calling nf_set_linker_options()")
endif()

# set extra linker flags
set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " ${ARGN}")
# request specs from newlib nano
set_property(TARGET ${NFSLO_TARGET} APPEND_STRING PROPERTY LINK_FLAGS " --specs=nano.specs ")

# set optimization linker flags for RELEASE and MinSizeRel
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
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 ")
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 ")
endif()

# include libraries in build
nf_include_libraries_in_build(${NFSLO_TARGET})

# set extra linker flags
set_property(TARGET ${NFSLO_TARGET} APPEND_STRING PROPERTY LINK_FLAGS " ${__EXTRA_LINK_FLAGS} ")

# set optimization flags
nf_set_optimization_options(${TARGET})

# set link map
nf_set_link_map(${TARGET})
nf_set_optimization_options(${NFSLO_TARGET})

endfunction()
endmacro()
Loading