Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
PonomarevDA committed Jan 5, 2024
1 parent 72721de commit b37be41
Showing 1 changed file with 76 additions and 62 deletions.
138 changes: 76 additions & 62 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,33 @@ else()
include(${ROOT_DIR}/Src/cyphal_application/CMakeLists.txt)
endif()

set(TOOLCHAIN_PREFIX arm-none-eabi-)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++)
set(CMAKE_CXX_STANDARD 20)

set(stm32cubeMxProjectPath ${ROOT_DIR}/Libs/stm32-cube-project)
FILE(GLOB coreSources ${stm32cubeMxProjectPath}/Core/Src/*)
FILE(GLOB driversSources ${stm32cubeMxProjectPath}/Drivers/STM32F1xx_HAL_Driver/Src/*.c*)

set(gitRelatedHeaders
${ROOT_DIR}/build/src
)

set(stm32CubeMxGeneratedFiles
${coreSources}
${driversSources}
${stm32cubeMxProjectPath}/startup_stm32f103xb.s
)
set(stm32CubeMxHeaders
${stm32cubeMxProjectPath}/Core/Inc
${stm32cubeMxProjectPath}/Drivers/CMSIS/Device/ST/STM32F1xx/Include
${stm32cubeMxProjectPath}/Drivers/CMSIS/Include
${stm32cubeMxProjectPath}/Drivers/STM32F1xx_HAL_Driver/Inc
${stm32cubeMxProjectPath}/Drivers/STM32F1xx_HAL_Driver/Inc/Legacy
)
if(USE_PLATFORM_UBUNTU)
message(SEND_ERROR "USE_PLATFORM_UBUNTU is not supported yet!")
else()
set(TOOLCHAIN_PREFIX arm-none-eabi-)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++)
set(CMAKE_CXX_STANDARD 20)
set(stm32cubeMxProjectPath ${ROOT_DIR}/Libs/stm32-cube-project)
FILE(GLOB coreSources ${stm32cubeMxProjectPath}/Core/Src/*)
FILE(GLOB driversSources ${stm32cubeMxProjectPath}/Drivers/STM32F1xx_HAL_Driver/Src/*.c*)
set(gitRelatedHeaders
${ROOT_DIR}/build/src
)
set(stm32CubeMxGeneratedFiles
${coreSources}
${driversSources}
${stm32cubeMxProjectPath}/startup_stm32f103xb.s
)
set(stm32CubeMxHeaders
${stm32cubeMxProjectPath}/Core/Inc
${stm32cubeMxProjectPath}/Drivers/CMSIS/Device/ST/STM32F1xx/Include
${stm32cubeMxProjectPath}/Drivers/CMSIS/Include
${stm32cubeMxProjectPath}/Drivers/STM32F1xx_HAL_Driver/Inc
${stm32cubeMxProjectPath}/Drivers/STM32F1xx_HAL_Driver/Inc/Legacy
)
endif()

set(EXECUTABLE ${PROJECT_NAME}.out)
add_executable(${EXECUTABLE}
Expand All @@ -52,10 +53,15 @@ add_executable(${EXECUTABLE}
${libsSourceCode}
${applicationSourceCode}
)
target_compile_definitions(${EXECUTABLE} PRIVATE
-DUSE_HAL_DRIVER
-DSTM32F103xB
)

if(USE_PLATFORM_UBUNTU)
message(SEND_ERROR "USE_PLATFORM_UBUNTU is not supported yet!")
else()
target_compile_definitions(${EXECUTABLE} PRIVATE
-DUSE_HAL_DRIVER
-DSTM32F103xB
)
endif()

include_directories(${libsHeaders})

Expand All @@ -67,44 +73,52 @@ target_include_directories(${EXECUTABLE} PRIVATE

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-volatile")

target_compile_options(${EXECUTABLE} PRIVATE
-mcpu=cortex-m3
-mthumb
-fdata-sections
-ffunction-sections
-lc -lm -lnosys
-specs=nano.specs
-Wall
--specs=nosys.specs
)
if(USE_PLATFORM_UBUNTU)
message(SEND_ERROR "USE_PLATFORM_UBUNTU is not supported yet!")
else()
target_compile_options(${EXECUTABLE} PRIVATE
-mcpu=cortex-m3
-mthumb
-fdata-sections
-ffunction-sections
-lc -lm -lnosys
-specs=nano.specs
-Wall
--specs=nosys.specs
)

target_link_options(${EXECUTABLE} PRIVATE
-T${stm32cubeMxProjectPath}/STM32F103T8Ux_FLASH.ld
-mcpu=cortex-m3
-mthumb
--specs=nosys.specs
-specs=nano.specs
-lc
-lm
-lnosys
-Wl,-Map=${PROJECT_NAME}.map,--cref
-Wl,--gc-sections
)
target_link_options(${EXECUTABLE} PRIVATE
-T${stm32cubeMxProjectPath}/STM32F103T8Ux_FLASH.ld
-mcpu=cortex-m3
-mthumb
--specs=nosys.specs
-specs=nano.specs
-lc
-lm
-lnosys
-Wl,-Map=${PROJECT_NAME}.map,--cref
-Wl,--gc-sections
)
endif()

if(NOT USE_DRONECAN)
execute_process(
COMMAND ${CMAKE_CURRENT_LIST_DIR}/scripts/prebuild_cyphal.sh ${cyphalRegisters}
)
endif()

add_custom_command(TARGET ${EXECUTABLE}
POST_BUILD
COMMAND arm-none-eabi-size ${EXECUTABLE}
)
if(USE_PLATFORM_UBUNTU)
message(SEND_ERROR "USE_PLATFORM_UBUNTU is not supported yet!")
else()
add_custom_command(TARGET ${EXECUTABLE}
POST_BUILD
COMMAND arm-none-eabi-size ${EXECUTABLE}
)

add_custom_command(TARGET ${EXECUTABLE}
POST_BUILD
COMMAND arm-none-eabi-objcopy -O ihex ${EXECUTABLE} ${PROJECT_NAME}.hex
COMMAND arm-none-eabi-objcopy -O binary ${EXECUTABLE} ${PROJECT_NAME}.bin
COMMAND arm-none-eabi-objcopy -I binary -O elf32-little ${EXECUTABLE} ${PROJECT_NAME}.elf
)
add_custom_command(TARGET ${EXECUTABLE}
POST_BUILD
COMMAND arm-none-eabi-objcopy -O ihex ${EXECUTABLE} ${PROJECT_NAME}.hex
COMMAND arm-none-eabi-objcopy -O binary ${EXECUTABLE} ${PROJECT_NAME}.bin
COMMAND arm-none-eabi-objcopy -I binary -O elf32-little ${EXECUTABLE} ${PROJECT_NAME}.elf
)
endif()

0 comments on commit b37be41

Please sign in to comment.