-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
executable file
·86 lines (62 loc) · 2.7 KB
/
CMakeLists.txt
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Copyright (c) 2022 Mr. Green's Workshop https://www.MrGreensWorkshop.com
# SPDX-License-Identifier: Apache-2.0
# Set minimum CMake version
cmake_minimum_required(VERSION 3.17)
# Include the subsidiary .cmake file to get the SDK
include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)
# Set the name and version of the project
project(PicoDRO VERSION 1.0.0)
# Set the board to Raspberry Pi Pico W
set(PICO_BOARD pico_w)
# Set top source code folder
set(SOURCE_FOLDER "src")
# Set build type (options: 'Debug', 'Release', 'MinSizeRel', 'RelWithDebInfo')
set(default_build_type "Release")
# Set CMAKE_BUILD_TYPE
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build, options are: 'Debug', 'Release', 'MinSizeRel', 'RelWithDebInfo'." FORCE)
# Initialize the SDK
pico_sdk_init()
# Add an executable target for the project
add_executable(${PROJECT_NAME})
# Get all the pio files, when the glob value changes, cmake will run again and update the files
file(GLOB_RECURSE pio_src CONFIGURE_DEPENDS "${SOURCE_FOLDER}/*.pio")
# Convert List to String
STRING(REPLACE ";" "\n" PIO_SRC_STR "${pio_src}")
# Print the pio source file list
#message(STATUS "PIO code source files: \n${PIO_SRC_STR}")
# If there are any PIO source files, include them to the build.
if (NOT pio_src STREQUAL "")
message(STATUS "Generate PIO headers: \n${pio_src}")
#pico_generate_pio_header(${PROJECT_NAME} "${PIO_SRC_STR}")
pico_generate_pio_header(${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}/src/quadrature_decoder.pio)
pico_generate_pio_header(${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}/src/pin_ctrl.pio)
endif()
# Get all C and C++ files, when the glob value changes, cmake will run again and update the files
file(GLOB_RECURSE app_src CONFIGURE_DEPENDS "${SOURCE_FOLDER}/*.c" "${SOURCE_FOLDER}/*.cpp" )
# Convert List to String
STRING(REPLACE ";" "\n" APP_SRC_STR "${app_src}")
# Print the C and C++ source file list
message(STATUS "C and C++ source files: \n${APP_SRC_STR}")
# Add C and C++ source files to the build
target_sources(${PROJECT_NAME} PRIVATE ${app_src})
# Link the Project to extra libraries
target_link_libraries(${PROJECT_NAME} PRIVATE
pico_stdlib
hardware_pio
pico_multicore
pico_btstack_classic
pico_btstack_cyw43
pico_cyw43_arch_none
)
# Including header files directly from project directory
target_include_directories(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}
)
# Export binaries like hex, bin, and uf2 files.
pico_add_extra_outputs(${PROJECT_NAME})
# Enable or Disable UART
pico_enable_stdio_uart(${PROJECT_NAME} 0)
# Enable or Disable USB CDC
pico_enable_stdio_usb(${PROJECT_NAME} 1)
# Disable DTR check for USB CDC connection
add_definitions(-DPICO_STDIO_USB_CONNECTION_WITHOUT_DTR=1)