diff options
| author | hathach <[email protected]> | 2023-05-26 16:37:47 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2023-05-26 16:37:47 +0700 |
| commit | 7ac85d08c7aa59f35cbbf2657dd9be68d46e1fdc (patch) | |
| tree | bbc4b7b31aee6554fb6768af6c85609122ed7e5e /src | |
| parent | 05cc342dfa258a2c5e381788009b84445b6e9856 (diff) | |
move lpc18 and rp2040 to cmake workflow since rp2040 often failed randomly with make
Diffstat (limited to 'src')
| -rw-r--r-- | src/CMakeLists.txt | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0d2f0975b..396737ed5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,11 +1,12 @@ -# TODO make tinyusb as library that depends on 'tusb_config' interface that exposes the tusb_config.h file -# This file is WIP and should not used yet +# 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.17) -# Add tinyusb to a target +# Add tinyusb to a target, if user don't want to compile tinyusb as a library function(add_tinyusb TARGET) - target_sources(${TARGET} PUBLIC + target_sources(${TARGET} PRIVATE # common ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/tusb.c ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/common/tusb_fifo.c @@ -37,11 +38,39 @@ function(add_tinyusb TARGET) # TODO for net driver, should be removed/changed ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../lib/networking ) - # enable all possible warnings - target_compile_options(${TARGET} PUBLIC - ) + + if (CMAKE_C_COMPILER_ID STREQUAL "GNU") + 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 + -Wreturn-type + -Wredundant-decls + ) + endif () endfunction() +#------------------------------------ +# TinyUSB as library target +#------------------------------------ set(TINYUSB_TARGET "tinyusb") set(TINYUSB_CONFIG_TARGET "tinyusb_config") @@ -58,12 +87,12 @@ endif () add_library(${TINYUSB_TARGET} STATIC) add_tinyusb(${TINYUSB_TARGET}) -# Link with tinyusb_config 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} ) |
