minor update

This commit is contained in:
hathach 2023-04-24 11:54:58 +07:00
parent 9858d45815
commit 5254202b20
4 changed files with 83 additions and 42 deletions

View File

@ -16,4 +16,39 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_SYSTEM_PROCESSOR) set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_SYSTEM_PROCESSOR)
include(${CMAKE_CURRENT_LIST_DIR}/../cpu/${CMAKE_SYSTEM_PROCESSOR}.cmake) include(${CMAKE_CURRENT_LIST_DIR}/../cpu/${CMAKE_SYSTEM_PROCESSOR}.cmake)
# enable all possible warnings for building examples
list(APPEND TOOLCHAIN_COMMON_FLAGS
-fdata-sections
-ffunction-sections
-fsingle-precision-constant
-fno-strict-aliasing
)
set(TOOLCHAIN_WARNING_FLAGS
-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
)
include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake) include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake)

View File

@ -1,22 +1,20 @@
get_property(IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE) include(CMakePrintHelpers)
# join the toolchain flags into a single string
list(JOIN TOOLCHAIN_COMMON_FLAGS " " TOOLCHAIN_COMMON_FLAGS)
foreach(LANG IN ITEMS C CXX ASM) foreach(LANG IN ITEMS C CXX ASM)
set(CMAKE_${LANG}_FLAGS_INIT "${TOOLCHAIN_COMMON_FLAGS}") # join the toolchain flags into a single string
if (PICO_DEOPTIMIZED_DEBUG) list(APPEND TOOLCHAIN_${LANG}_FLAGS ${TOOLCHAIN_COMMON_FLAGS})
set(CMAKE_${LANG}_FLAGS_DEBUG_INIT "-O0") list(JOIN TOOLCHAIN_${LANG}_FLAGS " " TOOLCHAIN_${LANG}_FLAGS)
else() set(CMAKE_${LANG}_FLAGS_INIT "${TOOLCHAIN_${LANG}_FLAGS}")
set(CMAKE_${LANG}_FLAGS_DEBUG_INIT "-Og")
endif()
set(CMAKE_${LANG}_LINK_FLAGS "-Wl,--build-id=none")
# try_compile is where the feature testing is done, and at that point, #cmake_print_variables(CMAKE_${LANG}_FLAGS_INIT)
# pico_standard_link is not ready to be linked in to provide essential
# functions like _exit. So pass -nostdlib so it doesn't link in an exit() # optimization flags
# function at all. set(CMAKE_${LANG}_FLAGS_DEBUG_INIT "-Og")
if(IS_IN_TRY_COMPILE)
set(CMAKE_${LANG}_LINK_FLAGS "${CMAKE_${LANG}_LINK_FLAGS} -nostdlib")
endif()
endforeach() endforeach()
# try_compile is cmake test compiling its own example,
# pass -nostdlib to skip stdlib linking
get_property(IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
if(IS_IN_TRY_COMPILE)
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -nostdlib")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -nostdlib")
endif()

View File

@ -19,8 +19,6 @@ function(family_configure_target TARGET)
include(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}/board.cmake) include(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}/board.cmake)
cmake_print_variables(TOP CMAKE_CURRENT_FUNCTION_LIST_DIR)
target_compile_definitions(${TARGET} PUBLIC target_compile_definitions(${TARGET} PUBLIC
CFG_TUSB_MCU=OPT_MCU_MIMXRT CFG_TUSB_MCU=OPT_MCU_MIMXRT
__ARMVFP__=0 __ARMVFP__=0
@ -77,6 +75,8 @@ function(family_configure_target TARGET)
# include tinyusb cmake # include tinyusb cmake
include(${TOP}/src/CMakeLists.txt) include(${TOP}/src/CMakeLists.txt)
add_tinyusb(${TARGET})
endfunction() endfunction()
function(family_add_freertos_config TARGET) function(family_add_freertos_config TARGET)

View File

@ -1,25 +1,33 @@
# cmake_minimum_required(VERSION 3.17) # cmake_minimum_required(VERSION 3.17)
# TODO make tinyusb as library that depends on 'tusb_config' interface that exposes the tusb_config.h file # TODO make tinyusb as library that depends on 'tusb_config' interface that exposes the tusb_config.h file
target_sources(${PROJECT} PUBLIC function(add_tinyusb TARGET)
${CMAKE_CURRENT_LIST_DIR}/tusb.c target_sources(${TARGET} PUBLIC
${CMAKE_CURRENT_LIST_DIR}/common/tusb_fifo.c ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/tusb.c
${CMAKE_CURRENT_LIST_DIR}/device/usbd.c ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/common/tusb_fifo.c
${CMAKE_CURRENT_LIST_DIR}/device/usbd_control.c ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/device/usbd.c
${CMAKE_CURRENT_LIST_DIR}/class/audio/audio_device.c ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/device/usbd_control.c
${CMAKE_CURRENT_LIST_DIR}/class/cdc/cdc_device.c ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/audio/audio_device.c
${CMAKE_CURRENT_LIST_DIR}/class/dfu/dfu_device.c ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/cdc/cdc_device.c
${CMAKE_CURRENT_LIST_DIR}/class/dfu/dfu_rt_device.c ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/dfu/dfu_device.c
${CMAKE_CURRENT_LIST_DIR}/class/hid/hid_device.c ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/dfu/dfu_rt_device.c
${CMAKE_CURRENT_LIST_DIR}/class/midi/midi_device.c ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/hid/hid_device.c
${CMAKE_CURRENT_LIST_DIR}/class/msc/msc_device.c ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/midi/midi_device.c
${CMAKE_CURRENT_LIST_DIR}/class/net/ecm_rndis_device.c ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/msc/msc_device.c
${CMAKE_CURRENT_LIST_DIR}/class/net/ncm_device.c ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/net/ecm_rndis_device.c
${CMAKE_CURRENT_LIST_DIR}/class/usbtmc/usbtmc_device.c ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/net/ncm_device.c
${CMAKE_CURRENT_LIST_DIR}/class/vendor/vendor_device.c ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/usbtmc/usbtmc_device.c
${CMAKE_CURRENT_LIST_DIR}/class/video/video_device.c ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/vendor/vendor_device.c
) ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/video/video_device.c
)
target_include_directories(${PROJECT} PUBLIC target_include_directories(${TARGET} PUBLIC
${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
) )
# enable all possible warnings
target_compile_options(${TARGET} PUBLIC
)
endfunction()