summaryrefslogtreecommitdiff
path: root/src/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/CMakeLists.txt')
-rw-r--r--src/CMakeLists.txt75
1 files changed, 4 insertions, 71 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index cf6878389..99d3059fc 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,11 +1,7 @@
-# TODO more docs and example on how to use this file
-# Usage: requires target tinyusb_config which expose tusb_config.h file
-# TINYUSB_TARGET_PREFIX and TINYUSB_TARGET_SUFFIX can be used to change the name of the target
+cmake_minimum_required(VERSION 3.20)
-cmake_minimum_required(VERSION 3.17)
-
-# Add tinyusb to a target, if user don't want to compile tinyusb as a library
-function(add_tinyusb TARGET)
+# Add tinyusb to a existing target, DCD and HCD drivers are not included
+function(tinyusb_target_add TARGET)
target_sources(${TARGET} PRIVATE
# common
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/tusb.c
@@ -30,6 +26,7 @@ function(add_tinyusb TARGET)
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/host/hub.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/cdc/cdc_host.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/hid/hid_host.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/midi/midi_host.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/msc/msc_host.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/vendor/vendor_host.c
# typec
@@ -40,68 +37,4 @@ function(add_tinyusb TARGET)
# TODO for net driver, should be removed/changed
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../lib/networking
)
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_compile_options(${TARGET} PRIVATE
- -Wall
- -Wextra
- -Werror
- -Wfatal-errors
- -Wdouble-promotion
- -Wstrict-prototypes
- -Wstrict-overflow
- -Werror-implicit-function-declaration
- -Wfloat-equal
- -Wundef
- -Wshadow
- -Wwrite-strings
- -Wsign-compare
- -Wmissing-format-attribute
- -Wunreachable-code
- -Wcast-align
- -Wcast-function-type
- -Wcast-qual
- -Wnull-dereference
- -Wuninitialized
- -Wunused
- -Wunused-function
- -Wreturn-type
- -Wredundant-decls
- -Wmissing-prototypes
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
-
- endif ()
endfunction()
-
-#------------------------------------
-# TinyUSB as library target
-#------------------------------------
-if (NOT DEFINED TINYUSB_TARGET)
- set(TINYUSB_TARGET "tinyusb")
-endif ()
-
-set(TINYUSB_CONFIG_TARGET "${TINYUSB_TARGET}_config")
-
-if (DEFINED TINYUSB_TARGET_PREFIX)
- set(TINYUSB_TARGET "${TINYUSB_TARGET_PREFIX}${TINYUSB_TARGET}")
- set(TINYUSB_CONFIG_TARGET "${TINYUSB_TARGET_PREFIX}${TINYUSB_CONFIG_TARGET}")
-endif ()
-
-if (DEFINED TINYUSB_TARGET_SUFFIX)
- set(TINYUSB_TARGET "${TINYUSB_TARGET}${TINYUSB_TARGET_SUFFIX}")
- set(TINYUSB_CONFIG_TARGET "${TINYUSB_CONFIG_TARGET}${TINYUSB_TARGET_SUFFIX}")
-endif ()
-
-add_library(${TINYUSB_TARGET} STATIC)
-add_tinyusb(${TINYUSB_TARGET})
-
-# Check if tinyusb_config target is defined
-if (NOT TARGET ${TINYUSB_CONFIG_TARGET})
- message(FATAL_ERROR "${TINYUSB_CONFIG_TARGET} target is not defined")
-endif()
-
-# Link with tinyusb_config target
-target_link_libraries(${TINYUSB_TARGET} PUBLIC
- ${TINYUSB_CONFIG_TARGET}
- )