Advertisement
evantill2

CMakeLists.txt

Oct 12th, 2022
1,811
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CMake 2.96 KB | None | 0 0
  1. cmake_minimum_required(VERSION 3.16)
  2.  
  3. #set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/extern/stm32-cmake/cmake/stm32_gcc.cmake)
  4. #set(STM32_CUBE_L4_PATH ${CMAKE_CURRENT_SOURCE_DIR}/extern/STM32CubeL4)
  5. #set(STM32_TOOLCHAIN_PATH /Applications/STMicroelectronics/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.macos64_1.0.0.202111181127/tools/bin)
  6.  
  7. if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
  8.   message(FATAL_ERROR "Specify path of stm32_gcc.cmake in CMAKE_TOOLCHAIN_FILE")
  9. endif()
  10.  
  11. if(NOT DEFINED STM32_CUBE_L4_PATH)
  12.   message(FATAL_ERROR "Specify stm32 L4 cube path in STM32_CUBE_L4_PATH")
  13. endif()
  14.  
  15. if(NOT DEFINED STM32_TOOLCHAIN_PATH)
  16.   message(FATAL_ERROR "Specify path to arm-none-eabi-gcc directory in STM32_TOOLCHAIN_PATH")
  17. endif()
  18.  
  19. project(TESTCMAKE20221004 C CXX ASM)
  20.  
  21. message(STATUS "CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}")
  22. message(STATUS "CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}")
  23. message(STATUS "STM32_CUBE_L4_PATH=${STM32_CUBE_L4_PATH}")
  24.  
  25. set(CMSIS_COMP_LIST
  26.   STM32L431RC
  27.   STM32L4_M4
  28.   RTOS_V2
  29. )
  30.  
  31. set(HAL_COMP_LIST
  32.   STM32L4
  33.   CORTEX
  34.   DMA
  35.   EXTI
  36.   FLASH
  37.   GPIO
  38.   I2C
  39.   IWDG
  40.   PWR
  41.   RCC
  42.   TIM
  43.   UART
  44. )
  45.  
  46. set(FREERTOS_COMP_LIST
  47.   ARM_CM4F
  48.   STM32L4
  49. )
  50.  
  51. find_package(CMSIS COMPONENTS "${CMSIS_COMP_LIST}" REQUIRED)
  52.  
  53. find_package(HAL COMPONENTS "${HAL_COMP_LIST}" REQUIRED)
  54.  
  55. find_package(FreeRTOS COMPONENTS ${FREERTOS_COMP_LIST} REQUIRED)
  56.  
  57. set(PROJECT_SOURCES
  58.   Core/Src/dma.c
  59.   Core/Src/freertos.c
  60.   Core/Src/gpio.c
  61.   Core/Src/iwdg.c
  62.   Core/Src/main.c
  63.   Core/Src/stm32l4xx_hal_msp.c
  64.   Core/Src/stm32l4xx_hal_timebase_tim.c
  65.   Core/Src/stm32l4xx_it.c
  66.   Core/Src/syscalls.c
  67.   Core/Src/sysmem.c
  68.   #Core/Src/system_stm32l4xx.c
  69.   Core/Src/usart.c
  70.   Core/Src/app/mainTask.c
  71.   Core/Src/app/interface/ledLife_hal.c
  72.   Core/Src/app/interface/watchdog_hal.c
  73.   Core/Src/lib/misc/stm32_console.c
  74. )
  75.  
  76. add_executable(TESTCMAKE20221004 ${PROJECT_SOURCES})
  77.  
  78. target_link_libraries(TESTCMAKE20221004
  79.   CMSIS::STM32::L431RC
  80.   HAL::STM32::L4::CORTEX
  81.   HAL::STM32::L4::DMA
  82.   HAL::STM32::L4::EXTI
  83.   HAL::STM32::L4::FLASH
  84.   HAL::STM32::L4::GPIO
  85.   HAL::STM32::L4::I2C
  86.   HAL::STM32::L4::IWDG
  87.   HAL::STM32::L4::PWR
  88.   HAL::STM32::L4::PWREx
  89.   HAL::STM32::L4::RCC
  90.   HAL::STM32::L4::RCCEx
  91.   HAL::STM32::L4::TIM
  92.   HAL::STM32::L4::TIMEx
  93.   HAL::STM32::L4::UART
  94.   HAL::STM32::L4::UARTEx
  95.   STM32::NoSys
  96.   FreeRTOS::STM32::L4::Timers
  97.   FreeRTOS::STM32::L4::Heap::4
  98.   FreeRTOS::STM32::L4::ARM_CM4F
  99.   CMSIS::STM32::L4::RTOS_V2
  100. )
  101.  
  102. target_include_directories(TESTCMAKE20221004 PRIVATE
  103.   Core/Inc
  104.   Core/Src/lib
  105.   Core/Src/lib/misc
  106.   Core/Src/app/interface
  107. )
  108.  
  109. stm32_print_size_of_target(TESTCMAKE20221004)
  110.  
  111. if(HAL_FOUND)
  112.   message(STATUS "using HAL Driver : add compile definition USE_HAL_DRIVER")
  113.   # Needed by stm32_console see docs/analyse/stm32_console_deps.puml
  114.   target_compile_definitions(TESTCMAKE20221004 PRIVATE USE_HAL_DRIVER)
  115. endif()
  116.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement