CMakeLists.txt 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #
  2. # wolfssl benchmark test
  3. #
  4. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS")
  5. set(COMPONENT_SRCS "main.c")
  6. set(COMPONENT_ADD_INCLUDEDIRS ".")
  7. set (git_cmd "git")
  8. if( EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl/" AND EXISTS "$ENV{IDF_PATH}/components/wolfssl/" )
  9. #
  10. # wolfSSL found in both ESP-IDF and local project - needs to be resolved by user
  11. #
  12. message(STATUS "")
  13. message(STATUS "WARNING: Found components/wolfssl in both local project and IDF_PATH")
  14. message(STATUS "")
  15. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_MULTI_INSTALL_WARNING")
  16. endif()
  17. idf_component_register(SRCS main.c
  18. INCLUDE_DIRS "."
  19. "./include")
  20. #
  21. # LIBWOLFSSL_SAVE_INFO(VAR_OUPUT THIS_VAR VAR_RESULT)
  22. #
  23. # Save the THIS_VAR as a string in a macro called VAR_OUPUT
  24. #
  25. # VAR_OUPUT: the name of the macro to define
  26. # THIS_VAR: the OUTPUT_VARIABLE result from a execute_process()
  27. # VAR_RESULT: the RESULT_VARIABLE from a execute_process(); "0" if successful.
  28. #
  29. function ( LIBWOLFSSL_SAVE_INFO VAR_OUPUT THIS_VAR VAR_RESULT )
  30. # is the RESULT_VARIABLE output value 0? If so, IS_VALID_VALUE is true.
  31. string(COMPARE EQUAL "${VAR_RESULT}" "0" IS_VALID_VALUE)
  32. # if we had a successful operation, save the THIS_VAR in VAR_OUPUT
  33. if(${IS_VALID_VALUE})
  34. # strip newline chars in THIS_VAR parameter and save in VAR_VALUE
  35. string(REPLACE "\n" "" VAR_VALUE ${THIS_VAR})
  36. # we'll could percolate the value to the parent for possible later use
  37. # set(${VAR_OUPUT} ${VAR_VALUE} PARENT_SCOPE)
  38. # but we're only using it here in this function
  39. set(${VAR_OUPUT} ${VAR_VALUE})
  40. # we'll print what we found to the console
  41. message(STATUS "Found ${VAR_OUPUT}=${VAR_VALUE}")
  42. # the interesting part is defining the VAR_OUPUT name a value to use in the app
  43. add_definitions(-D${VAR_OUPUT}=\"${VAR_VALUE}\")
  44. else()
  45. # if we get here, check the execute_process command and parameters.
  46. message(STATUS "LIBWOLFSSL_SAVE_INFO encountered a non-zero VAR_RESULT")
  47. set(${VAR_OUPUT} "Unknown")
  48. endif()
  49. endfunction() # LIBWOLFSSL_SAVE_INFO
  50. if(NOT CMAKE_BUILD_EARLY_EXPANSION)
  51. # LIBWOLFSSL_VERSION_GIT_HASH
  52. execute_process(COMMAND ${git_cmd} "rev-parse" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET )
  53. LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH "${TMP_OUT}" "${TMP_RES}")
  54. # LIBWOLFSSL_VERSION_GIT_SHORT_HASH
  55. execute_process(COMMAND ${git_cmd} "rev-parse" "--short" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET )
  56. LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_SHORT_HASH "${TMP_OUT}" "${TMP_RES}")
  57. # LIBWOLFSSL_VERSION_GIT_HASH_DATE
  58. execute_process(COMMAND ${git_cmd} "show" "--no-patch" "--no-notes" "--pretty=\'\%cd\'" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES )
  59. LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH_DATE "${TMP_OUT}" "${TMP_RES}")
  60. endif()
  61. message(STATUS "")