1##
2##   ______                              _
3##  / _____)             _              | |
4## ( (____  _____ ____ _| |_ _____  ____| |__
5##  \____ \| ___ |    (_   _) ___ |/ ___)  _ \
6##  _____) ) ____| | | || |_| ____( (___| | | |
7## (______/|_____)_|_|_| \__)_____)\____)_| |_|
8## (C)2013-2017 Semtech
9##  ___ _____ _   ___ _  _____ ___  ___  ___ ___
10## / __|_   _/_\ / __| |/ / __/ _ \| _ \/ __| __|
11## \__ \ | |/ _ \ (__| ' <| _| (_) |   / (__| _|
12## |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
13## embedded.connectivity.solutions.==============
14##
15## License:  Revised BSD License, see LICENSE.TXT file included in the project
16## Authors:  Johannes Bruder (STACKFORCE), Miguel Luis (Semtech)
17##
18project(tx-cw)
19cmake_minimum_required(VERSION 3.6)
20
21#---------------------------------------------------------------------------------------
22# Options
23#---------------------------------------------------------------------------------------
24
25# Allow selection of region
26option(REGION_EU868 "Region EU868" ON)
27option(REGION_US915 "Region US915" OFF)
28option(REGION_CN779 "Region CN779" OFF)
29option(REGION_EU433 "Region EU433" OFF)
30option(REGION_AU915 "Region AU915" OFF)
31option(REGION_AS923 "Region AS923" OFF)
32option(REGION_CN470 "Region CN470" OFF)
33option(REGION_KR920 "Region KR920" OFF)
34option(REGION_IN865 "Region IN865" OFF)
35option(REGION_RU864 "Region RU864" OFF)
36set(REGION_LIST REGION_EU868 REGION_US915 REGION_CN779 REGION_EU433 REGION_AU915 REGION_AS923 REGION_CN470 REGION_KR920 REGION_IN865 REGION_RU864)
37
38#---------------------------------------------------------------------------------------
39# Target
40#---------------------------------------------------------------------------------------
41
42file(GLOB ${PROJECT_NAME}_SOURCES "${CMAKE_CURRENT_LIST_DIR}/${BOARD}/*.c")
43
44add_executable(${PROJECT_NAME}
45                            ${${PROJECT_NAME}_SOURCES}
46                            $<TARGET_OBJECTS:system>
47                            $<TARGET_OBJECTS:radio>
48                            $<TARGET_OBJECTS:peripherals>
49                            $<TARGET_OBJECTS:${BOARD}>
50)
51
52# Loops through all regions and add compile time definitions for the enabled ones.
53foreach( REGION ${REGION_LIST} )
54    if(${REGION})
55        target_compile_definitions(${PROJECT_NAME} PUBLIC -D"${REGION}")
56    endif()
57endforeach()
58
59target_compile_definitions(${PROJECT_NAME}  PUBLIC
60    $<BUILD_INTERFACE:$<TARGET_PROPERTY:mac,INTERFACE_COMPILE_DEFINITIONS>>
61)
62
63target_include_directories(${PROJECT_NAME} PUBLIC
64    $<BUILD_INTERFACE:$<TARGET_PROPERTY:system,INTERFACE_INCLUDE_DIRECTORIES>>
65    $<BUILD_INTERFACE:$<TARGET_PROPERTY:radio,INTERFACE_INCLUDE_DIRECTORIES>>
66    $<BUILD_INTERFACE:$<TARGET_PROPERTY:peripherals,INTERFACE_INCLUDE_DIRECTORIES>>
67    $<BUILD_INTERFACE:$<TARGET_PROPERTY:${BOARD},INTERFACE_INCLUDE_DIRECTORIES>>
68)
69
70set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 11)
71
72target_link_libraries(${PROJECT_NAME} m)
73
74#---------------------------------------------------------------------------------------
75# Debugging and Binutils
76#---------------------------------------------------------------------------------------
77
78include(gdb-helper)
79include(binutils-arm-none-eabi)
80
81# Generate debugger configurations
82generate_run_gdb_stlink(${PROJECT_NAME})
83generate_run_gdb_openocd(${PROJECT_NAME})
84generate_vscode_launch_openocd(${PROJECT_NAME})
85
86# Print section sizes of target
87print_section_sizes(${PROJECT_NAME})
88
89# Create output in hex and binary format
90create_bin_output(${PROJECT_NAME})
91create_hex_output(${PROJECT_NAME})
92