CMakeLists.txt 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. cmake_minimum_required(VERSION 3.13)
  2. set(PICO_BOARD pico_w)
  3. include($ENV{PICO_SDK_PATH}/pico_sdk_init.cmake)
  4. project(pico-peer)
  5. pico_sdk_init()
  6. include(FreeRTOS_Kernel_import.cmake)
  7. include(${CMAKE_CURRENT_LIST_DIR}/../../third_party/coreHTTP/httpFilePaths.cmake)
  8. include(${CMAKE_CURRENT_LIST_DIR}/../../third_party/coreMQTT/mqttFilePaths.cmake)
  9. include_directories(
  10. ${CMAKE_CURRENT_LIST_DIR}/
  11. ${CMAKE_BINARY_DIR}/
  12. ${CMAKE_CURRENT_LIST_DIR}/../../third_party/libsrtp/include/
  13. ${CMAKE_CURRENT_LIST_DIR}/../../third_party/libsrtp/crypto/include/
  14. ${CMAKE_CURRENT_LIST_DIR}/../../third_party/cJSON/
  15. ${CMAKE_CURRENT_LIST_DIR}/../../src/
  16. ${HTTP_INCLUDE_PUBLIC_DIRS}
  17. ${MQTT_INCLUDE_PUBLIC_DIRS}
  18. )
  19. set(PICO_SDK_LIBS
  20. pico_stdlib
  21. pico_cyw43_arch_lwip_sys_freertos
  22. pico_mbedtls
  23. FreeRTOS-Kernel-Heap4
  24. )
  25. # Build libsrtp
  26. file(GLOB LIBSRTP_SRC
  27. ../../third_party/libsrtp/srtp/srtp.c
  28. ../../third_party/libsrtp/crypto/cipher/cipher.c
  29. ../../third_party/libsrtp/crypto/cipher/null_cipher.c
  30. ../../third_party/libsrtp/crypto/cipher/aes.c
  31. ../../third_party/libsrtp/crypto/cipher/aes_icm.c
  32. ../../third_party/libsrtp/crypto/cipher/cipher_test_cases.c
  33. ../../third_party/libsrtp/crypto/hash/auth.c
  34. ../../third_party/libsrtp/crypto/hash/null_auth.c
  35. ../../third_party/libsrtp/crypto/hash/hmac.c
  36. ../../third_party/libsrtp/crypto/hash/sha1.c
  37. ../../third_party/libsrtp/crypto/hash/auth_test_cases.c
  38. ../../third_party/libsrtp/crypto/kernel/alloc.c
  39. ../../third_party/libsrtp/crypto/kernel/crypto_kernel.c
  40. ../../third_party/libsrtp/crypto/kernel/err.c
  41. ../../third_party/libsrtp/crypto/kernel/key.c
  42. ../../third_party/libsrtp/crypto/math/datatypes.c
  43. ../../third_party/libsrtp/crypto/math/stat.c
  44. ../../third_party/libsrtp/crypto/replay/rdb.c
  45. ../../third_party/libsrtp/crypto/replay/rdbx.c
  46. ../../third_party/libsrtp/crypto/replay/ut_sim.c
  47. )
  48. add_library(srtp STATIC
  49. ${LIBSRTP_SRC}
  50. )
  51. target_compile_definitions(srtp PRIVATE
  52. HAVE_CONFIG_H
  53. PRIx64=PRIx32
  54. )
  55. target_link_libraries(srtp
  56. ${PICO_SDK_LIBS}
  57. )
  58. add_custom_command(TARGET srtp
  59. POST_BUILD
  60. COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/srtp2/
  61. COMMAND ${CMAKE_COMMAND} -E copy
  62. ../../../third_party/libsrtp/include/srtp.h
  63. ${CMAKE_BINARY_DIR}/srtp2/
  64. )
  65. # Build cJSON
  66. add_library(cjson STATIC
  67. ../../third_party/cJSON/cJSON.c
  68. )
  69. # Build peer
  70. file(GLOB LIBPEER_SRC "../../src/*.c")
  71. add_library(peer STATIC
  72. ${LIBPEER_SRC}
  73. ${HTTP_SOURCES}
  74. ${MQTT_SOURCES}
  75. ${MQTT_SERIALIZER_SOURCES}
  76. )
  77. target_compile_definitions(peer PRIVATE
  78. __BYTE_ORDER=__LITTLE_ENDIAN
  79. CONFIG_USE_LWIP=1
  80. CONFIG_USE_USRSCTP=0
  81. CONFIG_MBEDTLS_2_X=1
  82. CONFIG_DATA_BUFFER_SIZE=512
  83. CONFIG_AUDIO_BUFFER_SIZE=2048
  84. CONFIG_HTTP_BUFFER_SIZE=1024
  85. CONFIG_SDP_BUFFER_SIZE=4096
  86. HTTP_DO_NOT_USE_CUSTOM_CONFIG
  87. MQTT_DO_NOT_USE_CUSTOM_CONFIG
  88. )
  89. target_link_libraries(peer
  90. ${PICO_SDK_LIBS}
  91. srtp
  92. cjson
  93. )
  94. pico_generate_pio_header(pico_peer ${CMAKE_CURRENT_LIST_DIR}/rp2040_i2s_example/i2s.pio)
  95. # Build pico_peer
  96. add_executable(pico_peer
  97. main.c
  98. rp2040_i2s_example/i2s.c
  99. pcm-g711/pcm-g711/g711.c
  100. )
  101. target_compile_definitions(pico_peer PRIVATE
  102. WIFI_SSID="$ENV{WIFI_SSID}"
  103. WIFI_PASSWORD="$ENV{WIFI_PASSWORD}"
  104. PICO_HEAP_SIZE=0x20000
  105. #PICO_DEBUG_MALLOC=1
  106. )
  107. target_link_libraries(pico_peer
  108. ${PICO_SDK_LIBS}
  109. peer
  110. )
  111. pico_enable_stdio_usb(pico_peer 1)
  112. pico_enable_stdio_uart(pico_peer 0)
  113. pico_add_extra_outputs(pico_peer)