- doxygen styling added - CDC -> ACM refactor - type refactoring - examples categorized - flatUSB_config.h examples added
81 lines
2.5 KiB
CMake
81 lines
2.5 KiB
CMake
cmake_minimum_required(VERSION 3.15)
|
|
|
|
set(FLATUSB_TARGET flatUSB)
|
|
|
|
if (FLATUSB_TARGET_TAG)
|
|
set(FLATUSB_TARGET "${FLATUSB_TARGET}_${FLATUSB_TARGET_TAG}")
|
|
message("Custom flatUSB target: ${FLATUSB_TARGET}")
|
|
endif()
|
|
|
|
set(FLATUSB_CLASSES_SRC "")
|
|
if ("CDC_ACM" IN_LIST FLATUSB_CLASSES)
|
|
list(APPEND FLATUSB_CLASSES_SRC
|
|
class/acm.c
|
|
class/acm.h
|
|
)
|
|
endif()
|
|
|
|
if ("CDC_EEM" IN_LIST FLATUSB_CLASSES)
|
|
list(APPEND FLATUSB_CLASSES_SRC
|
|
class/eem.c
|
|
class/eem.h
|
|
)
|
|
endif()
|
|
|
|
if (FLATUSB_DESC_DIR)
|
|
AUX_SOURCE_DIRECTORY(${FLATUSB_DESC_DIR} FLATUSB_DESC_SRC)
|
|
set(FLATUSB_DESC_HEADER ${FLATUSB_DESC_DIR}/usb_desc.h)
|
|
if (FLATUSB_DESC_SRC)
|
|
message("flatUSB descriptors: " ${FLATUSB_DESC_SRC})
|
|
else()
|
|
message("flatUSB descriptors: (empty)")
|
|
endif()
|
|
elseif(NOT FLATUSB_DESC_SRC)
|
|
message("flatUSB: No source of descriptors passed! Please either set FLATUSB_DESC_DIR to the directory containing the descriptor files OR pass descriptor files directly by defining FLATUSB_DESC_SRC and FLATUSB_DESC_HEADER!")
|
|
endif()
|
|
|
|
if (NOT FLATUSB_DRIVER_SRC)
|
|
message("flatUSB: No USB driver passed! It's likely an error and not intentional. Please populate FLATUSB_DRIVER_SRC with the list of the USB driver files!")
|
|
endif()
|
|
|
|
message("flatUSB classes selected: ${FLATUSB_CLASSES}")
|
|
|
|
set(FLATUSB_SRC
|
|
${FLATUSB_CLASSES_SRC}
|
|
${FLATUSB_DESC_SRC}
|
|
${FLATUSB_DRIVER_SRC}
|
|
|
|
usb.c
|
|
usb_callback_event.h
|
|
usb_common.h
|
|
usb_common_types.h
|
|
usb_device_types.h
|
|
#usb_driver.c
|
|
#usb_driver.h
|
|
usb.h
|
|
|
|
# utils/gen_queue.c
|
|
# utils/gen_queue.h
|
|
)
|
|
|
|
add_library(${FLATUSB_TARGET} STATIC ${FLATUSB_SRC})
|
|
target_include_directories(${FLATUSB_TARGET} PRIVATE ${FLATUSB_INCLUDES} ${CMAKE_CURRENT_LIST_DIR})
|
|
target_compile_options(${FLATUSB_TARGET} PRIVATE ${FLATUSB_CPU_PARAMS})
|
|
target_compile_definitions(${FLATUSB_TARGET} PRIVATE ${FLATUSB_COMPILE_DEFS})
|
|
target_compile_definitions(${FLATUSB_TARGET} PRIVATE FLATUSB_DESCRIPTOR_HEADER="${FLATUSB_DESC_HEADER}")
|
|
|
|
if (FLATUSB_DESC_JSON AND FLATUSB_DESC_DIR)
|
|
message("flatUSB: descriptor JSON passed: " ${FLATUSB_DESC_JSON})
|
|
message("flatUSB: also defining flatUSB-gen-desc target")
|
|
add_custom_target(
|
|
flatUSB-gen-desc
|
|
COMMAND python3 ${CMAKE_CURRENT_LIST_DIR}/desc-gen/main.py ${FLATUSB_DESC_JSON} ${FLATUSB_DESC_DIR}
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
|
)
|
|
endif()
|
|
|
|
add_custom_target(
|
|
flatUSB-docs
|
|
COMMAND doxygen
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
|
) |