CMakelists.txt 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. # This file is in the 'test' directory of your project
  2. cmake_minimum_required(VERSION 3.5)
  3. set(PROJECT_VER $ENV{PROJECT_VER})
  4. add_definitions(-DMODEL_NAME=SqueezeESP32)
  5. if(NOT DEFINED DEPTH)
  6. set(DEPTH "16")
  7. endif()
  8. # State machine hierarchy enabled and logging enabled
  9. add_definitions(-DSTATE_MACHINE_LOGGER=1)
  10. add_definitions(-DHIERARCHICAL_STATES=1)
  11. add_definitions(-DTESTPROJECT=1)
  12. # Align the nanopb library options across the entire project
  13. # otherwise this results in nasty structures misalignment
  14. # when implementing callbacks
  15. add_definitions(-DPB_ENABLE_MALLOC -DPB_FIELD_32BIT)
  16. # Include the components directory to make the main components available
  17. set(EXTRA_COMPONENT_DIRS "../components")
  18. # Register the test components directory
  19. list(APPEND EXTRA_COMPONENT_DIRS "test_main")
  20. # Include the main ESP-IDF CMakeLists file
  21. include($ENV{IDF_PATH}/tools/cmake/project.cmake)
  22. # Set the components to include the tests for.
  23. # This can be overriden from CMake cache:
  24. # - when invoking CMake directly: cmake -D TEST_COMPONENTS="xxxxx" ..
  25. # - when using idf.py: idf.py -T xxxxx build
  26. #
  27. set(TEST_COMPONENTS "platform_config" "tools" "wifi-manager" CACHE STRING "List of components to test")
  28. # manually add the console squeezelite component
  29. list(APPEND EXTRA_COMPONENT_DIRS ../components/platform_console/recovery )
  30. # Set the project name
  31. project(squeezelite-esp32-test-project)
  32. add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../protobuf ${CMAKE_CURRENT_BINARY_DIR}/protobuf)
  33. add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../spiffs_src ${CMAKE_CURRENT_BINARY_DIR}/spiffs)
  34. # get_target_property(BCA recovery.elf LINK_LIBRARIES)
  35. # list(REMOVE_ITEM BCA "idf::app_squeezelite" "idf::app_recovery" "-Wl,--Map=${BUILD_DIR}/recovery.map" "-Wl,--cref -Wl,--Map=${BUILD_DIR}/recovery.map")
  36. # set_target_properties(recovery.elf PROPERTIES LINK_LIBRARIES "${BCA};idf::app_recovery;-Wl,--Map=${BUILD_DIR}/recovery.map")
  37. # TODO: enable gcov. this was attempted, but caused some
  38. # tasks to crash with "Cache disabled but cached memory region accessed"
  39. # when SPIFFS was being used.
  40. #
  41. idf_create_coverage_report(${CMAKE_CURRENT_BINARY_DIR}/coverage_report)
  42. idf_clean_coverage_report(${CMAKE_CURRENT_BINARY_DIR}/coverage_report)
  43. # # This is the project CMakeLists.txt file for the test subproject
  44. # cmake_minimum_required(VERSION 3.5)
  45. # include($ENV{IDF_PATH}/tools/cmake/project.cmake)
  46. # # Include the components directory of the main application:
  47. # #
  48. # # Set the components to include the tests for.
  49. # # This can be overriden from CMake cache:
  50. # # - when invoking CMake directly: cmake -D TEST_COMPONENTS="xxxxx" ..
  51. # # - when using idf.py: idf.py -T xxxxx build
  52. # #
  53. # set(TEST_COMPONENTS "platform_console" CACHE STRING "List of components to test")
  54. # set(COMPONENTS main)
  55. # # Freertos is included via common components, however, currently only the mock component is compatible with linux
  56. # # target.
  57. # list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/")
  58. # list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/driver/")
  59. # list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/")
  60. # list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/spi_flash/")
  61. # list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/components/unity/")
  62. # idf_build_set_property(COMPILE_DEFINITIONS "-DNO_DEBUG_STORAGE" APPEND)
  63. # # list(APPEND EXTRA_COMPONENT_DIRS "${PROJECT_SOURCE_DIR}/../components")
  64. # # list(APPEND EXTRA_COMPONENT_DIRS "${PROJECT_SOURCE_DIR}/../components/tools")
  65. # project(squeezelite_esp32_test)
  66. # # add_definitions(-include "${PROJECT_SOURCE_DIR}/../build/config/sdkconfig.h")
  67. # set_property(TARGET squeezelite_esp32_test.elf PROPERTY RECOVERY_PREFIX app_update )
  68. add_custom_command(
  69. OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/build/coverage.info"
  70. WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build"
  71. COMMAND lcov --capture --directory . --output-file coverage.info
  72. COMMENT "Create coverage report"
  73. )
  74. add_custom_command(
  75. OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/build/coverage_report/"
  76. DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/build/coverage.info"
  77. WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build"
  78. COMMAND genhtml coverage.info --output-directory coverage_report/
  79. COMMENT "Turn coverage report into html-based visualization"
  80. )
  81. add_custom_target(coverage
  82. WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build"
  83. DEPENDS "coverage_report/"
  84. )