summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: 7d886710402486f538d673c764e1bcb92031ed77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
cmake_minimum_required(VERSION 3.6)
set(MCU_CHIP stm32f103C6)
set(MCU_USE_STM32CUBE TRUE)
set(MCU_LTO_MODE OFF)
include(thirdparty/mcu.cmake/mcu.cmake)
project(radio-controller C CXX ASM)

set(CMAKE_CXX_STANDARD 14)

include(thirdparty/mcucpp/cmake/mcucpp.cmake)

add_executable(firmware src/radio-controller.cpp
  include/decoder.h
  include/misc.h
  include/radio-controller.h
  include)
target_compile_definitions(firmware PUBLIC MCUCMAKE_USING_STM32CUBE=1)
target_include_directories(firmware PUBLIC include)
target_link_libraries(firmware PUBLIC gcc)
mcu_add_executable(TARGET firmware)

mcucpp_configure_target(TARGET firmware)

# mcu.cmake sources
target_include_directories(firmware PUBLIC
  thirdparty/mcu.cmake/stm32f103/include
  )
target_sources(firmware PUBLIC
  #  thirdparty/mcu.cmake/stm32f103/src/default_handler.cpp
  thirdparty/mcu.cmake/stm32f103/src/init_high.cpp
  #  thirdparty/mcu.cmake/stm32f103/src/init_low.s
  thirdparty/mcu.cmake/stm32f103/src/init_stm32f103_ld.cpp
  thirdparty/mcu.cmake/stm32f103/src/init_low_halt.s
  thirdparty/mcu.cmake/stm32f103/src/init_low_Reset_Handler.s
  thirdparty/mcu.cmake/stm32f103/src/breakpoint.s
  $ENV{HOME}/opt/STM32CubeMX/Repository/STM32Cube_FW_F1_V1.4.0/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xb.s
  )

mcucpp_process(TARGET firmware)

# BSP sources
mcu_include_directories_from_sources(
  SOURCE_DIR bsp/radio-controller-1
  EXCLUDE Templates
  EXCLUDE _template.c
  EXCLUDE Examples
  EXCLUDE DSP_Lib
  SOURCES_VAR BSP_SOURCES
  HEADERS_VAR BSP_HEADERS
  INCLUDES_VAR BSP_INCLUDES
)
list(FILTER BSP_INCLUDES INCLUDE REGEX Inc)
target_include_directories(firmware PUBLIC ${BSP_INCLUDES})
target_sources(firmware PUBLIC ${BSP_SOURCES} ${BSP_HEADERS})

ExternalProject_Add(build-tests
  SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/test
#  EXCLUDE_FROM_ALL TRUE
  CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}"
  INSTALL_COMMAND "")

add_custom_target(run-tests ALL
  COMMAND ${CMAKE_BINARY_DIR}/tests-prefix/src/tests-build/tests
  DEPENDS build-tests
  )