CMakeLists.txt 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. # Check that there are not conflicting wolfSSL components
  49. # The ESP Registry Component will be in ./managed_components/wolfssl__wolfssl
  50. # The local component wolfSSL directory will be in ./components/wolfssl
  51. if( EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" AND EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl" )
  52. # These exclude statements don't seem to be honored by the $ENV{IDF_PATH}/tools/cmake/project.cmake'
  53. # add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" EXCLUDE_FROM_ALL)
  54. # add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl/include" EXCLUDE_FROM_ALL)
  55. # So we'll error out and let the user decide how to proceed:
  56. message(WARNING "\nFound wolfSSL components in\n"
  57. "./managed_components/wolfssl__wolfssl\n"
  58. "and\n"
  59. "./components/wolfssl\n"
  60. "in project directory: \n"
  61. "${CMAKE_HOME_DIRECTORY}")
  62. message(FATAL_ERROR "\nPlease use either the ESP Registry Managed Component or the wolfSSL component directory but not both.\n"
  63. "If removing the ./managed_components/wolfssl__wolfssl directory, remember to also remove "
  64. "or rename the idf_component.yml file typically found in ./main/")
  65. else()
  66. message(STATUS "No conflicting wolfSSL components found.")
  67. endif()
  68. include($ENV{IDF_PATH}/tools/cmake/project.cmake)
  69. project(wolfssl_template)