Skip to content

Commit 2ac2896

Browse files
committed
clean up
1 parent b42d3e4 commit 2ac2896

File tree

4 files changed

+60
-52
lines changed

4 files changed

+60
-52
lines changed
Lines changed: 44 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
cmake_minimum_required(VERSION 3.13)
2-
include(CMakePrintHelpers)
3-
4-
# default toolchain is gcc
5-
if (NOT TOOLCHAIN)
6-
set(TOOLCHAIN "gcc")
7-
endif ()
82

93
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/family_support.cmake)
104

@@ -16,54 +10,54 @@ project(${PROJECT} C CXX ASM)
1610
# Checks this example is valid for the family and initializes the project
1711
family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
1812

19-
# Other family such as rp2040
20-
if(NOT FAMILY STREQUAL "espressif")
21-
add_executable(${PROJECT})
22-
23-
# Example source
24-
target_sources(${PROJECT} PUBLIC
25-
${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
26-
)
13+
# Espressif has its own cmake build system
14+
if(FAMILY STREQUAL "espressif")
15+
return()
16+
endif()
2717

28-
# Example include
29-
target_include_directories(${PROJECT} PUBLIC
30-
${CMAKE_CURRENT_SOURCE_DIR}/src
31-
)
18+
add_executable(${PROJECT})
3219

33-
if(FAMILY STREQUAL "rp2040")
34-
# Configure compilation flags and libraries for the example... see the corresponding function
35-
# in hw/bsp/FAMILY/family.cmake for details.
36-
family_configure_device_example(${PROJECT})
37-
else ()
38-
# TOP is absolute path to root directory of TinyUSB git repo
39-
set(TOP "${CMAKE_CURRENT_LIST_DIR}/../../..")
40-
get_filename_component(TOP "${TOP}" REALPATH)
20+
# Example source
21+
target_sources(${PROJECT} PUBLIC
22+
${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
23+
)
4124

42-
# re-include family.cmake
43-
include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
25+
# Example include
26+
target_include_directories(${PROJECT} PUBLIC
27+
${CMAKE_CURRENT_SOURCE_DIR}/src
28+
)
4429

45-
target_sources(${PROJECT} PUBLIC
46-
${TOP}/src/device/usbd.c
47-
${TOP}/src/device/usbd_control.c
48-
${TOP}/src/class/audio/audio_device.c
49-
${TOP}/src/class/cdc/cdc_device.c
50-
${TOP}/src/class/dfu/dfu_device.c
51-
${TOP}/src/class/dfu/dfu_rt_device.c
52-
${TOP}/src/class/hid/hid_device.c
53-
${TOP}/src/class/midi/midi_device.c
54-
${TOP}/src/class/msc/msc_device.c
55-
${TOP}/src/class/net/ecm_rndis_device.c
56-
${TOP}/src/class/net/ncm_device.c
57-
${TOP}/src/class/usbtmc/usbtmc_device.c
58-
${TOP}/src/class/vendor/vendor_device.c
59-
${TOP}/src/class/video/video_device.c
60-
)
30+
if(FAMILY STREQUAL "rp2040")
31+
# Configure compilation flags and libraries for the example... see the corresponding function
32+
# in hw/bsp/FAMILY/family.cmake for details.
33+
family_configure_device_example(${PROJECT})
34+
else ()
35+
# TOP is absolute path to root directory of TinyUSB git repo
36+
set(TOP "${CMAKE_CURRENT_LIST_DIR}/../../..")
37+
get_filename_component(TOP "${TOP}" REALPATH)
6138

62-
target_include_directories(${PROJECT} PUBLIC
63-
${TOP}/hw
64-
${TOP}/src
65-
)
39+
# re-include family.cmake
40+
include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
6641

42+
target_sources(${PROJECT} PUBLIC
43+
${TOP}/src/device/usbd.c
44+
${TOP}/src/device/usbd_control.c
45+
${TOP}/src/class/audio/audio_device.c
46+
${TOP}/src/class/cdc/cdc_device.c
47+
${TOP}/src/class/dfu/dfu_device.c
48+
${TOP}/src/class/dfu/dfu_rt_device.c
49+
${TOP}/src/class/hid/hid_device.c
50+
${TOP}/src/class/midi/midi_device.c
51+
${TOP}/src/class/msc/msc_device.c
52+
${TOP}/src/class/net/ecm_rndis_device.c
53+
${TOP}/src/class/net/ncm_device.c
54+
${TOP}/src/class/usbtmc/usbtmc_device.c
55+
${TOP}/src/class/vendor/vendor_device.c
56+
${TOP}/src/class/video/video_device.c
57+
)
6758

68-
endif ()
69-
endif()
59+
target_include_directories(${PROJECT} PUBLIC
60+
${TOP}/hw
61+
${TOP}/src
62+
)
63+
endif ()

examples/device/cdc_msc/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/family_support.cmake)
55
# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
66
family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
77

8-
project(${PROJECT})
8+
project(${PROJECT} C CXX ASM)
99

1010
# Checks this example is valid for the family and initializes the project
1111
family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
1212

13+
# Espressif has its own cmake build system
14+
if(FAMILY STREQUAL "espressif")
15+
return()
16+
endif()
17+
1318
add_executable(${PROJECT})
1419

1520
# Example source

hw/bsp/family_support.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
if (NOT TARGET _family_support_marker)
2+
include(CMakePrintHelpers)
3+
4+
# Default to gcc
5+
if(NOT DEFINED TOOLCHAIN)
6+
set(TOOLCHAIN gcc)
7+
endif()
8+
29
add_library(_family_support_marker INTERFACE)
310

411
if (NOT FAMILY)

hw/bsp/imxrt/family.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
# toolchain set up, include before project()
1+
2+
23
if (NOT TARGET ${PROJECT})
4+
# toolchain set up, include before project()
35
set(CMAKE_SYSTEM_PROCESSOR cortex-m7 CACHE INTERNAL "System Processor")
46
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../../cmake/toolchain/arm_${TOOLCHAIN}.cmake)
57
else ()

0 commit comments

Comments
 (0)