CMakeLists.txt 4.1 KB

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