CMakeLists.txt 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. # wolfSSL Espressif Example Project CMakeLists.txt
  2. # v1.0
  3. #
  4. # The following lines of boilerplate have to be in your project's
  5. # CMakeLists in this exact order for cmake to work correctly
  6. message(STATUS "Begin project ${CMAKE_PROJECT_NAME}")
  7. cmake_minimum_required(VERSION 3.16)
  8. # The wolfSSL CMake file should be able to find the source code.
  9. # Otherwise, assign an environment variable or set it here:
  10. #
  11. # set(WOLFSSL_ROOT "~/workspace/wolfssl-other-source")
  12. #
  13. # Optional WOLFSSL_CMAKE_SYSTEM_NAME detection to find
  14. # USE_MY_PRIVATE_CONFIG path for my_private_config.h
  15. #
  16. # Expected path varies:
  17. #
  18. # WSL: /mnt/c/workspace
  19. # Linux: ~/workspace
  20. # Windows: C:\workspace
  21. #
  22. if(WIN32)
  23. # Windows-specific configuration here
  24. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS")
  25. message("Detected Windows")
  26. endif()
  27. if(CMAKE_HOST_UNIX)
  28. message("Detected UNIX")
  29. endif()
  30. if(APPLE)
  31. message("Detected APPLE")
  32. endif()
  33. if(CMAKE_HOST_UNIX AND (NOT APPLE) AND EXISTS "/proc/sys/fs/binfmt_misc/WSLInterop")
  34. # Windows-specific configuration here
  35. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WSL")
  36. message("Detected WSL")
  37. endif()
  38. if(CMAKE_HOST_UNIX AND (NOT APPLE) AND (NOT WIN32))
  39. # Windows-specific configuration here
  40. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_LINUX")
  41. message("Detected Linux")
  42. endif()
  43. if(APPLE)
  44. # Windows-specific configuration here
  45. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_APPLE")
  46. message("Detected Apple")
  47. endif()
  48. # End optional WOLFSSL_CMAKE_SYSTEM_NAME
  49. # This example uses an extra component for common functions such as Wi-Fi and Ethernet connection.
  50. # set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
  51. string(REPLACE "\\" "/" PROTOCOL_EXAMPLES_DIR "$ENV{IDF_PATH}/examples/common_components/protocol_examples_common")
  52. if (EXISTS "${PROTOCOL_EXAMPLES_DIR}")
  53. message("Found PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}")
  54. set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
  55. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFOUND_PROTOCOL_EXAMPLES_DIR")
  56. else()
  57. message("NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}")
  58. endif()
  59. # Check that there are not conflicting wolfSSL components
  60. # The ESP Registry Component will be in ./managed_components/wolfssl__wolfssl
  61. # The local component wolfSSL directory will be in ./components/wolfssl
  62. if( EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" AND EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl" )
  63. # These exclude statements don't seem to be honored by the $ENV{IDF_PATH}/tools/cmake/project.cmake'
  64. # add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" EXCLUDE_FROM_ALL)
  65. # add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl/include" EXCLUDE_FROM_ALL)
  66. # So we'll error out and let the user decide how to proceed:
  67. message(WARNING "\nFound wolfSSL components in\n"
  68. "./managed_components/wolfssl__wolfssl\n"
  69. "and\n"
  70. "./components/wolfssl\n"
  71. "in project directory: \n"
  72. "${CMAKE_HOME_DIRECTORY}")
  73. message(FATAL_ERROR "\nPlease use either the ESP Registry Managed Component or the wolfSSL component directory but not both.\n"
  74. "If removing the ./managed_components/wolfssl__wolfssl directory, remember to also remove "
  75. "or rename the idf_component.yml file typically found in ./main/")
  76. else()
  77. message(STATUS "No conflicting wolfSSL components found.")
  78. endif()
  79. message(STATUS "begin include")
  80. if(0)
  81. # This example uses an extra component for common functions such as Wi-Fi and Ethernet connection.
  82. set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
  83. if (EXISTS "${PROTOCOL_EXAMPLES_DIR}")
  84. message("Found PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}")
  85. set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
  86. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFOUND_PROTOCOL_EXAMPLES_DIR")
  87. else()
  88. message("NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}")
  89. endif()
  90. endif()
  91. include($ENV{IDF_PATH}/tools/cmake/project.cmake)
  92. message(STATUS "end include")
  93. project(wolfssl_server)
  94. message(STATUS "end project")