### CMake project setup and build configurations Source: https://github.com/eclipse-threadx/usbx/blob/master/test/cmake/usbx/CMakeLists.txt Configures the USBX test project, sets up custom user header, copies library files, and defines multiple build configurations. ```cmake cmake_minimum_required(VERSION 3.13 FATAL_ERROR) cmake_policy(SET CMP0054 NEW) cmake_policy(SET CMP0057 NEW) cmake_policy(SET CMP0077 NEW) project(usbx_test LANGUAGES C) # Use customized ux_user.h set(UX_USER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/ux_user.h) # Copy files instead of using symlink # libs/ -> ../libs/ file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/libs) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../libs/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/libs/CMakeLists.txt COPYONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../libs/nx_user.h ${CMAKE_CURRENT_SOURCE_DIR}/libs/nx_user.h COPYONLY) # Set build configurations # TODO: add when available : standalone_otg_build set(BUILD_CONFIGURATIONS default_build_coverage error_check_build_full_coverage tracex_enable_build device_buffer_owner_build device_zero_copy_build nofx_build_coverage optimized_build standalone_device_build_coverage standalone_device_buffer_owner_build standalone_device_zero_copy_build standalone_host_build_coverage standalone_build_coverage generic_build otg_support_build memory_management_build_coverage msrc_rtos_build msrc_standalone_build ) set(CMAKE_CONFIGURATION_TYPES ${BUILD_CONFIGURATIONS} CACHE STRING "list of supported configuration types" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES}) list(GET CMAKE_CONFIGURATION_TYPES 0 BUILD_TYPE) if((NOT CMAKE_BUILD_TYPE) OR (NOT ("${CMAKE_BUILD_TYPE}" IN_LIST CMAKE_CONFIGURATION_TYPES))) set(CMAKE_BUILD_TYPE "${BUILD_TYPE}" CACHE STRING "Build Type of the project" FORCE) endif() message(STATUS "Build for usbx") message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.") set(default_build_coverage -DNX_PHYSICAL_HEADER=20 ``` -------------------------------- ### Function header comment with version placeholder Source: https://github.com/eclipse-threadx/usbx/blob/master/README.md Example of a function header comment block used in USBX source files, showing the format for documenting function purpose, inputs, outputs, calls, and revision history. The version '6.x' indicates the file is not yet officially released. ```c /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _tx_initialize_low_level Cortex-M23/GNU */ /* 6.x */ /* AUTHOR */ /* */ /* Scott Larson, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This function is responsible for any low-level processor */ /* initialization, including setting up interrupt vectors, setting */ /* up a periodic timer interrupt source, saving the system stack */ /* pointer for use in ISR processing later, and finding the first */ /* available RAM memory address for tx_application_define. */ /* */ /* INPUT */ /* */ /* None */ /* */ /* OUTPUT */ /* */ /* None */ /* */ /* CALLS */ /* */ /* None */ /* */ /* CALLED BY */ /* */ /* _tx_initialize_kernel_enter ThreadX entry function */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 09-30-2020 Scott Larson Initial Version 6.1 */ /* xx-xx-xxxx Scott Larson Include tx_user.h, */ /* resulting in version 6.x */ /* */ /**************************************************************************/ ``` -------------------------------- ### Clone USBX repository Source: https://github.com/eclipse-threadx/usbx/blob/master/README.md Clones the Eclipse ThreadX USBX repository from GitHub. Use this as the first step after installing the required tools and building the ThreadX library dependency. ```bash $ git clone https://github.com/eclipse-threadx/usbx.git ``` -------------------------------- ### Configure and build libs with ThreadX, NetX Duo, and FileX Source: https://github.com/eclipse-threadx/usbx/blob/master/test/cmake/libs/CMakeLists.txt CMake configuration for building the libs project. It selects 32-bit or 64-bit build based on the ENABLE_64 environment variable, adds subdirectories for ThreadX, NetX Duo, and FileX, sets compile options for each library, and creates symlinks for all header files into the build's inc directory. ```cmake cmake_minimum_required(VERSION 3.13 FATAL_ERROR) project(libs LANGUAGES C) if($ENV{ENABLE_64}) message(STATUS "Building for 64bit") set(NX_USER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/nx_user.h) else() add_compile_options(-m32) add_link_options(-m32) message(STATUS "Building for 32bit") endif() message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.") get_filename_component(externals ${CMAKE_CURRENT_SOURCE_DIR}/../../../externals ABSOLUTE) add_subdirectory(${externals}/threadx threadx) add_subdirectory(${externals}/netxduo netxduo) add_subdirectory(${externals}/filex filex) target_compile_options(threadx PRIVATE -DTX_ENABLE_EVENT_TRACE) if(NOT DEFINED ENV{ENABLE_IDLE}) target_compile_options(threadx PRIVATE -DTX_LINUX_NO_IDLE_ENABLE) endif() target_compile_options(filex PRIVATE -DFX_ENABLE_EXFAT) target_compile_options(netxduo PRIVATE -DTX_ENABLE_EVENT_TRACE -DNX_PHYSICAL_HEADER=20) foreach(lib threadx netxduo filex) get_target_property(dirs ${lib} INCLUDE_DIRECTORIES) execute_process(COMMAND mkdir -p ${CMAKE_BINARY_DIR}/inc) foreach(dir ${dirs}) file(GLOB header_files ${dir}/*.h) foreach(header_file ${header_files}) execute_process(COMMAND ln -sf ${header_file} ${CMAKE_BINARY_DIR}/inc) endforeach() endforeach() endforeach() ``` -------------------------------- ### USBX CMakeLists.txt - Full Build Configuration Source: https://github.com/eclipse-threadx/usbx/blob/master/CMakeLists.txt Defines the USBX library target, links required dependencies, selects the port-specific subdirectory, copies the user configuration file, and enables a ZIP source package. ```cmake cmake_minimum_required(VERSION 3.13 FATAL_ERROR) # Set up the project project(usbx LANGUAGES C ASM ) if(NOT DEFINED THREADX_ARCH) message(FATAL_ERROR "Error: THREADX_ARCH not defined") endif() if(NOT DEFINED THREADX_TOOLCHAIN) message(FATAL_ERROR "Error: THREADX_TOOLCHAIN not defined") endif() # Define our target library and an alias for consumers add_library(${PROJECT_NAME}) add_library("azrtos::${PROJECT_NAME}" ALIAS ${PROJECT_NAME}) # Define any required dependencies between this library and others target_link_libraries(${PROJECT_NAME} PUBLIC "azrtos::threadx" "azrtos::filex" "azrtos::netxduo" ) # A place for generated/copied include files set(CUSTOM_INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/custom_inc) # Pick up the port specific stuff first if(DEFINED USBX_CUSTOM_PORT) add_subdirectory(${USBX_CUSTOM_PORT} usbx_port) else() add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/ports/${THREADX_ARCH}/${THREADX_TOOLCHAIN}) endif() # Then the common files add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/common) # If the user provided an override, copy it to the custom directory if (NOT UX_USER_FILE) message(STATUS "Using default ux_user.h file") set(UX_USER_FILE ${CMAKE_CURRENT_LIST_DIR}/common/core/inc/ux_user_sample.h) else() message(STATUS "Using custom ux_user.h file from ${UX_USER_FILE}") endif() configure_file(${UX_USER_FILE} ${CUSTOM_INC_DIR}/ux_user.h COPYONLY) target_include_directories(${PROJECT_NAME} PUBLIC ${CUSTOM_INC_DIR} ) target_compile_definitions(${PROJECT_NAME} PUBLIC "UX_INCLUDE_USER_DEFINE_FILE" ) # Enable a build target that produces a ZIP file of all sources set(CPACK_SOURCE_GENERATOR "ZIP") set(CPACK_SOURCE_IGNORE_FILES \.git/ \.github/ _build/ \.git \.gitattributes \.gitignore ".*~$" ) set(CPACK_VERBATIM_VARIABLES YES) include(CPack) ``` -------------------------------- ### Import ThreadX, NetX Duo, and FileX libraries Source: https://github.com/eclipse-threadx/usbx/blob/master/test/cmake/usbx/CMakeLists.txt Imports shared libraries for ThreadX, NetX Duo, and FileX as SHARED IMPORTED targets, creates aliases with 'azrtos::' prefix, and sets their IMPORTED_LOCATION properties. ```cmake add_library(threadx SHARED IMPORTED GLOBAL) add_library("azrtos::threadx" ALIAS threadx) set_target_properties( threadx PROPERTIES IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/../libs/threadx/libthreadx.so) add_library(netxduo SHARED IMPORTED GLOBAL) add_library("azrtos::netxduo" ALIAS netxduo) set_target_properties( netxduo PROPERTIES IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/../libs/netxduo/libnetxduo.so) add_library(filex SHARED IMPORTED GLOBAL) add_library("azrtos::filex" ALIAS filex) set_target_properties( filex PROPERTIES IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/../libs/filex/libfilex.so) ``` -------------------------------- ### Enable testing and add subdirectories Source: https://github.com/eclipse-threadx/usbx/blob/master/test/cmake/usbx/CMakeLists.txt Enables testing and adds the USBX source directory. For generic_build, it adds a fake test; otherwise, it adds the regression subdirectory. It also adds the samples subdirectory unless the build type matches 'standalone.*'. ```cmake enable_testing() add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../../../ usbx) if(CMAKE_BUILD_TYPE STREQUAL "generic_build") add_test(fake_test true) else() add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/regression regression) endif() # TODO: Unmask after adding sample for STANDALONE if(NOT (CMAKE_BUILD_TYPE MATCHES "standalone.*")) add_subdirectory(../usbx/samples samples) endif() ``` -------------------------------- ### Build USBX static library for Cortex-M4 with CMake Source: https://github.com/eclipse-threadx/usbx/blob/master/README.md Configures and builds the USBX library as a standalone static library for Cortex-M4 using the provided CMake toolchain file. Run these commands from the repository root after cloning. ```bash $ cmake -Bbuild -GNinja -DCMAKE_TOOLCHAIN_FILE=cmake/cortex_m4.cmake . $ cmake --build ./build ``` -------------------------------- ### Directory layout tree Source: https://github.com/eclipse-threadx/usbx/blob/master/README.md Shows the top-level directory structure of the USBX repository, including cmake, common, ports, samples, support, and license/contribution files. ```text . ├── cmake # CMakeList files for building the project ├── common # Core USBX files ├── ports # Architecture and compiler specific files ├── samples # Sample codes ├── support # Misc platform configurations file used by USBX ├── LICENSE.txt # License terms ├── LICENSE-HARDWARE.txt # Licensed hardware from semiconductors ├── CONTRIBUTING.md # Contribution guidance └── SECURITY.md # Repo security guidance ``` -------------------------------- ### Control 64-bit or 32-bit build Source: https://github.com/eclipse-threadx/usbx/blob/master/test/cmake/usbx/CMakeLists.txt Checks the ENABLE_64 environment variable. If set, it builds for 64-bit; otherwise, it adds -m32 compile and link options for 32-bit builds. ```cmake if($ENV{ENABLE_64}) message(STATUS "Building for 64bit") else() add_compile_options(-m32) add_link_options(-m32) message(STATUS "Building for 32bit") endif() ``` -------------------------------- ### Build ThreadX library and add custom target Source: https://github.com/eclipse-threadx/usbx/blob/master/test/cmake/usbx/CMakeLists.txt Runs the run.sh script to build libraries and creates a custom target 'build_libs' that depends on the usbx target. It also adds the library include directory. ```cmake execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/run.sh build_libs) add_custom_target(build_libs ALL COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/run.sh build_libs) add_dependencies(usbx build_libs) target_include_directories(usbx PUBLIC ${CMAKE_BINARY_DIR}/../libs/inc) ``` -------------------------------- ### Use generic port file for generic build Source: https://github.com/eclipse-threadx/usbx/blob/master/test/cmake/usbx/CMakeLists.txt Replaces the Linux GNU port include path with the generic port path when building with the 'generic_build' configuration, updating the usbx target's include directories accordingly. ```cmake if(CMAKE_BUILD_TYPE STREQUAL "generic_build") get_target_property(INCLUDES_LIST usbx INCLUDE_DIRECTORIES) set(NEW_INCLUDES_LIST "") foreach(INCLUDE_LIST ${INCLUDES_LIST}) string(REPLACE "ports/linux/gnu" "ports/generic" INCLUDE_LIST ${INCLUDE_LIST}) list(APPEND NEW_INCLUDES_LIST "${INCLUDE_LIST}") endforeach() set_target_properties(usbx PROPERTIES INCLUDE_DIRECTORIES "${NEW_INCLUDES_LIST}") endif() ``` -------------------------------- ### Set USBX target compile options Source: https://github.com/eclipse-threadx/usbx/blob/master/test/cmake/usbx/CMakeLists.txt Adds a comprehensive set of warning and error flags to the usbx target's private compile options, including -Werror, -Wall, -Wextra, and various other warnings. ```cmake target_compile_options( usbx PRIVATE -Werror -Wall -Wextra -pedantic -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -Wunused -Wuninitialized -Wmissing-declarations -Wconversion -Wpointer-arith -Wshadow -Wlogical-op -Waggregate-return -Wfloat-equal) ``` -------------------------------- ### Configure USBX regression tests based on build type Source: https://github.com/eclipse-threadx/usbx/blob/master/test/cmake/usbx/regression/CMakeLists.txt Selects the test case list based on CMAKE_BUILD_TYPE patterns (msrc_rtos_build, msrc_standalone_build, nofx_, memory_management_, standalone_device, standalone_host, optimized). Then iterates over the selected test cases, creating an executable for each, linking it to test_utility, and registering a CTest test named with the build type prefix. ```cmake if (CMAKE_BUILD_TYPE MATCHES "msrc_rtos_build") set(test_cases ${ux_msrc_test_cases} ${ux_msrc_test_cases_rtos} ) elseif (CMAKE_BUILD_TYPE MATCHES "msrc_standalone_build") set(test_cases ${ux_msrc_test_cases} ${ux_msrc_test_cases_standalone} ) elseif(NOT (CMAKE_BUILD_TYPE MATCHES "standalone.*")) if (CMAKE_BUILD_TYPE MATCHES "nofx_.*") set(test_cases ${ux_class_storage_test_cases} ) elseif (CMAKE_BUILD_TYPE MATCHES "memory_management_.*") set(test_cases ${ux_class_memory_management_test_cases} ) else() set(test_cases ${ux_basic_test_cases} ${ux_utility_test_cases} ${ux_utility_os_test_cases} ${ux_stack_test_cases} ${ux_dpump_test_cases} ${ux_class_hub_test_cases} ${ux_device_class_storage_tx_test_cases} ${ux_class_dfu_test_cases} ${ux_class_print_test_cases} ${ux_class_ccid_test_cases} ) if(NOT (CMAKE_BUILD_TYPE MATCHES "optimized.*")) list(APPEND test_cases ${ux_stack_test_cases_hid} ${ux_stack_test_cases_cdc} ${ux_stack_cdc_acm_test_cases} ${ux_class_cdc_acm_test_cases} ${ux_class_audio_test_cases} ${ux_class_rndis_test_cases} ${ux_class_cdc_ecm_test_cases} ${ux_class_hid_test_cases} ${ux_class_video_test_cases} ${ux_class_storage_test_cases} ${ux_class_pima_test_cases} ${ux_class_gser_test_cases} ${ux_class_prolific_test_cases} ${ux_class_swar_test_cases} ${ux_msrc_test_cases} ) endif() endif() else() set(test_cases ${ux_basic_test_cases} ${ux_utility_test_cases} ${ux_dpump_test_cases} ) if (CMAKE_BUILD_TYPE MATCHES "standalone_device.*") list(APPEND test_cases ${ux_utility_os_test_cases} ${ux_class_storage_device_standalone_test_cases} ${ux_class_cdc_acm_device_standalone_test_cases} ${ux_class_video_device_standalone_test_cases} ${ux_class_hid_device_standalone_test_cases} ${ux_class_dfu_test_cases} ${ux_msrc_test_cases} ${ux_class_printer_device_standalone_test_cases} ${ux_class_audio_device_standalone_test_cases} ${ux_class_ccid_test_cases} ) elseif (CMAKE_BUILD_TYPE MATCHES "standalone_host.*") list(APPEND test_cases ${ux_utility_os_test_cases} ${ux_class_storage_host_standalone_test_cases} ${ux_class_cdc_acm_host_standalone_test_cases} ${ux_class_hid_host_standalone_test_cases} ${ux_class_print_test_cases} ${ux_class_hub_standalone_test_cases} ) else () list(APPEND test_cases ${ux_class_dfu_test_cases} ) endif() endif() ``` ```cmake foreach(test_case ${test_cases}) get_filename_component(test_name ${test_case} NAME_WE) add_executable(${test_name} ${test_case}) target_link_libraries(${test_name} PRIVATE test_utility) add_test(${CMAKE_BUILD_TYPE}::${test_name} ${test_name}) endforeach() ``` -------------------------------- ### Set common compile options Source: https://github.com/eclipse-threadx/usbx/blob/master/test/cmake/usbx/CMakeLists.txt Adds common compile options for C99, debugging symbols, and defines UMX_USE_IO_INSTRUCTIONS. Includes commented-out options for DFU custom request and status mode. ```cmake add_compile_options( -std=c99 -ggdb -g3 -gdwarf-2 -fdiagnostics-color -DUX_USE_IO_INSTRUCTIONS #-DUX_DEVICE_CLASS_DFU_CUSTOM_REQUEST_ENABLE #-DUX_DEVICE_CLASS_DFU_STATUS_MODE=1 ${${CMAKE_BUILD_TYPE}}) ``` -------------------------------- ### Add coverage compile and link options Source: https://github.com/eclipse-threadx/usbx/blob/master/test/cmake/usbx/CMakeLists.txt If the build type matches '.*_coverage', adds coverage flags to the usbx target's compile and link options. ```cmake if(CMAKE_BUILD_TYPE MATCHES ".*_coverage") target_compile_options(usbx PRIVATE -fprofile-arcs -ftest-coverage) target_link_options(usbx PRIVATE -fprofile-arcs -ftest-coverage) endif() ``` -------------------------------- ### Filter sources and includes for standalone builds Source: https://github.com/eclipse-threadx/usbx/blob/master/test/cmake/usbx/CMakeLists.txt Filters source lists and includes based on build type. For standalone_build_coverage, removes files not supporting STANDALONE and clears library links. For standalone_host_build_coverage, filters host-specific exclusions. standalone_otg_build makes no changes. ```cmake if(CMAKE_BUILD_TYPE MATCHES "standalone.*") get_target_property(test_utility_SOURCES_LIST test_utility SOURCES) get_target_property(SOURCES_LIST usbx SOURCES) get_target_property(INCLUDES_LIST usbx INCLUDE_DIRECTORIES) if("${CMAKE_BUILD_TYPE}" STREQUAL "standalone_build_coverage") # TODO: enable when STANDALONE implement is done # Remove files not support STANDALONE yet foreach(EXCLUDE_VAL ${UX_STANDALONE_HOST_EXCLUDES} ${UX_STANDALONE_DEVICE_EXCLUDES} ${UX_STANDALONE_UTILITY_EXCLUDES} ${UX_STANDALONE_PICTBRIDGE_EXCLUDES} ${UX_STANDALONE_NX_EXCLUDES} ${UX_STANDALONE_FX_EXCLUDES}) list(FILTER test_utility_SOURCES_LIST EXCLUDE REGEX ".*${EXCLUDE_VAL}.*") list(FILTER SOURCES_LIST EXCLUDE REGEX ".*${EXCLUDE_VAL}.*") endforeach() # Update includes to remove TX,FX,NX libs list(FILTER INCLUDES_LIST EXCLUDE REGEX ".*externals.*") list(FILTER INCLUDES_LIST EXCLUDE REGEX ".*/libs/inc.*") # Update library links to remove TX,FX,NX libs set_target_properties(usbx PROPERTIES LINK_LIBRARIES "") set_target_properties(usbx PROPERTIES INTERFACE_LINK_LIBRARIES "") elseif("${CMAKE_BUILD_TYPE}" STREQUAL "standalone_host_build_coverage") # Only host part linked with STANDALONE # Remove files not support STANDALONE yet foreach(EXCLUDE_VAL ${UX_STANDALONE_HOST_EXCLUDES}) list(FILTER SOURCES_LIST EXCLUDE REGEX ".*${EXCLUDE_VAL}.*") list(FILTER test_utility_SOURCES_LIST EXCLUDE REGEX ".*${EXCLUDE_VAL}.*") endforeach() elseif("${CMAKE_BUILD_TYPE}" STREQUAL "standalone_otg_build") # Only some stack file linked with STANDALONE # No file list change for now endif() ``` -------------------------------- ### Define standalone exclusion lists Source: https://github.com/eclipse-threadx/usbx/blob/master/test/cmake/usbx/CMakeLists.txt Defines CMake lists of USBX components to exclude from standalone builds. Each list groups related components (host classes, device classes, utilities, etc.) with commented-out entries as placeholders. ```cmake set(UX_STANDALONE_HOST_EXCLUDES # ux_host_class_asix # ux_host_class_audio # ux_host_class_cdc_acm # ux_host_class_cdc_ecm # ux_host_class_gser # ux_host_class_hid # ux_host_class_hub # ux_host_class_pima # ux_host_class_printer # ux_host_class_prolific # ux_host_class_storage # ux_host_class_swar # ux_host_class_video # ux_hcd_ehci # ux_hcd_ohci ) ``` ```cmake set(UX_STANDALONE_DEVICE_EXCLUDES # ux_device_class_audio # ux_device_class_cdc_acm # ux_device_class_cdc_ecm # ux_device_class_dfu # ux_device_class_hid # ux_device_class_pima # ux_device_class_rndis # ux_device_class_ccid # ux_device_class_printer # ux_device_class_video ) ``` ```cmake set(UX_STANDALONE_UTILITY_EXCLUDES # ux_utility_event # ux_utility_delay # ux_utility_mutex # ux_utility_semaphore # ux_utility_thread # ux_utility_timer ) ``` ```cmake set(UX_STANDALONE_PICTBRIDGE_EXCLUDES # ux_pictbridge ) ``` ```cmake set(UX_STANDALONE_NX_EXCLUDES # ux_network_driver ) ``` ```cmake set(UX_STANDALONE_FX_EXCLUDES # ux_host_class_storage_driver_entry usbx_ux_host_class_storage_fx_driver ) ``` -------------------------------- ### Control static/shared build and coverage flags Source: https://github.com/eclipse-threadx/usbx/blob/master/test/cmake/usbx/CMakeLists.txt Checks the USBX_STATIC environment variable to set BUILD_SHARED_LIBS OFF for static builds. If not static, it uses the existing BUILD_SHARED_LIBS value. When building static with a coverage build type, it adds coverage link options. ```cmake if($ENV{USBX_STATIC}) message(STATUS "Building STATIC usbx") set(BUILD_SHARED_LIBS OFF) else() message(STATUS "Building usbx BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}") endif() if(NOT BUILD_SHARED_LIBS) if(CMAKE_BUILD_TYPE MATCHES ".*_coverage") add_link_options(-fprofile-arcs) add_link_options(-lgcov) endif() endif() ``` -------------------------------- ### Filter sources for optimized build Source: https://github.com/eclipse-threadx/usbx/blob/master/test/cmake/usbx/CMakeLists.txt Defines a list of files to exclude (e.g., ux_device_class_rndis) and removes them from the test_utility and usbx source lists when building with the 'optimized_build' configuration. ```cmake set(UX_OPTIMIZED_EXCLUDES ux_device_class_rndis # buffer smaller than message size ) if(CMAKE_BUILD_TYPE STREQUAL "optimized_build") get_target_property(test_utility_SOURCES_LIST test_utility SOURCES) get_target_property(SOURCES_LIST usbx SOURCES) # Remove files not support STANDALONE yet foreach(EXCLUDE_VAL ${UX_OPTIMIZED_EXCLUDES}) list(FILTER test_utility_SOURCES_LIST EXCLUDE REGEX ".*${EXCLUDE_VAL}.*") list(FILTER SOURCES_LIST EXCLUDE REGEX ".*${EXCLUDE_VAL}.*") endforeach() # Commit sources and includes changes set_target_properties(test_utility PROPERTIES SOURCES "${test_utility_SOURCES_LIST}") set_target_properties(usbx PROPERTIES SOURCES "${SOURCES_LIST}") endif() ``` -------------------------------- ### Set target properties for test_utility and usbx Source: https://github.com/eclipse-threadx/usbx/blob/master/test/cmake/usbx/CMakeLists.txt Commits the modified source and include lists to the test_utility and usbx targets. This is used after filtering sources for optimized builds. ```cmake set_target_properties(test_utility PROPERTIES SOURCES "${test_utility_SOURCES_LIST}") set_target_properties(usbx PROPERTIES SOURCES "${SOURCES_LIST}") set_target_properties(usbx PROPERTIES INCLUDE_DIRECTORIES "${INCLUDES_LIST}") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.