|
@@ -1,5 +1,5 @@
|
|
#
|
|
#
|
|
-# Copyright (C) 2006-2023 wolfSSL Inc.
|
|
|
|
|
|
+# Copyright (C) 2006-2024 wolfSSL Inc.
|
|
#
|
|
#
|
|
# This file is part of wolfSSL.
|
|
# This file is part of wolfSSL.
|
|
#
|
|
#
|
|
@@ -19,16 +19,95 @@
|
|
#
|
|
#
|
|
# cmake for wolfssl Espressif projects
|
|
# cmake for wolfssl Espressif projects
|
|
#
|
|
#
|
|
-# Version 5.6.0.011 for detect test/benchmark
|
|
|
|
|
|
+# Version 5.7.0 template update + THIS_IDF_PATH
|
|
#
|
|
#
|
|
# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html
|
|
# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html
|
|
#
|
|
#
|
|
|
|
|
|
cmake_minimum_required(VERSION 3.16)
|
|
cmake_minimum_required(VERSION 3.16)
|
|
|
|
+
|
|
|
|
+set(VERBOSE_COMPONENT_MESSAGES 1)
|
|
|
|
+
|
|
|
|
+# The scope of this CMAKE_C_FLAGS is just this component:
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS")
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS")
|
|
|
|
+
|
|
set(CMAKE_CURRENT_SOURCE_DIR ".")
|
|
set(CMAKE_CURRENT_SOURCE_DIR ".")
|
|
-set(COMPONENT_REQUIRES lwip) # we typically don't need lwip directly in wolfssl component
|
|
|
|
-set(WOLFSSL_ROOT "$ENV{WOLFSSL_ROOT}" )
|
|
|
|
|
|
+# set(COMPONENT_REQUIRES lwip) # we typically don't need lwip directly in wolfssl component
|
|
|
|
+
|
|
|
|
+# Optionally set your source to wolfSSL in your project CMakeLists.txt like this:
|
|
|
|
+# set(WOLFSSL_ROOT "c:/test/my_wolfssl" )
|
|
|
|
+
|
|
|
|
+if ( "${WOLFSSL_ROOT}" STREQUAL "")
|
|
|
|
+ set(WOLFSSL_ROOT "$ENV{WOLFSSL_ROOT}" )
|
|
|
|
+endif()
|
|
|
|
+
|
|
|
|
+if( "$ENV{IDF_PATH}" STREQUAL "" )
|
|
|
|
+ message(FATAL_ERROR "IDF_PATH Environment variable not set!")
|
|
|
|
+else()
|
|
|
|
+ string(REPLACE "\\" "/" THIS_IDF_PATH "$ENV{IDF_PATH}")
|
|
|
|
+endif()
|
|
|
|
+
|
|
|
|
+# Optional compiler definitions to help with system name detection (typically printed by app diagnostics)
|
|
|
|
+if(VERBOSE_COMPONENT_MESSAGES)
|
|
|
|
+ if(WIN32)
|
|
|
|
+ # Windows-specific configuration here
|
|
|
|
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS")
|
|
|
|
+ message("Detected Windows")
|
|
|
|
+ endif()
|
|
|
|
+ if(CMAKE_HOST_UNIX)
|
|
|
|
+ message("Detected UNIX")
|
|
|
|
+ endif()
|
|
|
|
+ if(APPLE)
|
|
|
|
+ message("Detected APPLE")
|
|
|
|
+ endif()
|
|
|
|
+ if(CMAKE_HOST_UNIX AND (NOT APPLE) AND EXISTS "/proc/sys/fs/binfmt_misc/WSLInterop")
|
|
|
|
+ # Windows-specific configuration here
|
|
|
|
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WSL")
|
|
|
|
+ message("Detected WSL")
|
|
|
|
+ endif()
|
|
|
|
+ if(CMAKE_HOST_UNIX AND (NOT APPLE) AND (NOT WIN32))
|
|
|
|
+ # Windows-specific configuration here
|
|
|
|
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_LINUX")
|
|
|
|
+ message("Detected Linux")
|
|
|
|
+ endif()
|
|
|
|
+ if(APPLE)
|
|
|
|
+ # Windows-specific configuration here
|
|
|
|
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_APPLE")
|
|
|
|
+ message("Detected Apple")
|
|
|
|
+ endif()
|
|
|
|
+endif() # End optional WOLFSSL_CMAKE_SYSTEM_NAME
|
|
|
|
+
|
|
|
|
+message(STATUS "CONFIG_TARGET_PLATFORM = ${CONFIG_TARGET_PLATFORM}")
|
|
|
|
+
|
|
|
|
+# Check that there are not conflicting wolfSSL components
|
|
|
|
+# The ESP Registry Component will be in ./managed_components/wolfssl__wolfssl
|
|
|
|
+# The local component wolfSSL directory will be in ./components/wolfssl
|
|
|
|
+if( EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" AND EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl" )
|
|
|
|
+ # These exclude statements don't seem to be honored by the $ENV{IDF_PATH}/tools/cmake/project.cmake'
|
|
|
|
+ # add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" EXCLUDE_FROM_ALL)
|
|
|
|
+ # add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl/include" EXCLUDE_FROM_ALL)
|
|
|
|
+ # So we'll error out and let the user decide how to proceed:
|
|
|
|
+ message(WARNING "\nFound wolfSSL components in\n"
|
|
|
|
+ "./managed_components/wolfssl__wolfssl\n"
|
|
|
|
+ "and\n"
|
|
|
|
+ "./components/wolfssl\n"
|
|
|
|
+ "in project directory: \n"
|
|
|
|
+ "${CMAKE_HOME_DIRECTORY}")
|
|
|
|
+ message(FATAL_ERROR "\nPlease use either the ESP Registry Managed Component or the wolfSSL component directory but not both.\n"
|
|
|
|
+ "If removing the ./managed_components/wolfssl__wolfssl directory, remember to also remove "
|
|
|
|
+ "or rename the idf_component.yml file typically found in ./main/")
|
|
|
|
+else()
|
|
|
|
+ message(STATUS "No conflicting wolfSSL components found.")
|
|
|
|
+endif()
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+# Don't include lwip requirement for benchmark and test apps.
|
|
|
|
+if( ("${CMAKE_PROJECT_NAME}" STREQUAL "wolfssl_benchmark") OR ("${CMAKE_PROJECT_NAME}" STREQUAL "wolfssl_test") )
|
|
|
|
+ message(STATUS "Not including lwip for ${CMAKE_PROJECT_NAME}")
|
|
|
|
+else()
|
|
|
|
+ # benchmark and test do not need wifi, everything else probably does:
|
|
|
|
+ set(COMPONENT_REQUIRES lwip) # we typically don't need lwip directly in wolfssl component
|
|
|
|
+endif()
|
|
|
|
|
|
# find the user name to search for possible "wolfssl-username"
|
|
# find the user name to search for possible "wolfssl-username"
|
|
message(STATUS "USERNAME = $ENV{USERNAME}")
|
|
message(STATUS "USERNAME = $ENV{USERNAME}")
|
|
@@ -45,6 +124,11 @@ else()
|
|
endif()
|
|
endif()
|
|
message(STATUS "THIS_USER = ${THIS_USER}")
|
|
message(STATUS "THIS_USER = ${THIS_USER}")
|
|
|
|
|
|
|
|
+if( "$ENV{IDF_PATH}" STREQUAL "" )
|
|
|
|
+ message(FATAL_ERROR "IDF_PATH Environment variable not set!")
|
|
|
|
+else()
|
|
|
|
+ string(REPLACE "\\" "/" THIS_IDF_PATH "$ENV{IDF_PATH}")
|
|
|
|
+endif()
|
|
|
|
|
|
# COMPONENT_NAME = wolfssl
|
|
# COMPONENT_NAME = wolfssl
|
|
# The component name is the directory name. "No feature to change this".
|
|
# The component name is the directory name. "No feature to change this".
|
|
@@ -71,27 +155,41 @@ function(IS_WOLFSSL_SOURCE DIRECTORY_PARAMETER RESULT)
|
|
endif()
|
|
endif()
|
|
endfunction()
|
|
endfunction()
|
|
|
|
|
|
|
|
+# *********************************************************************************************
|
|
# function: FIND_WOLFSSL_DIRECTORY
|
|
# function: FIND_WOLFSSL_DIRECTORY
|
|
# parameter: OUTPUT_FOUND_WOLFSSL_DIRECTORY contains root of source code, otherwise blank
|
|
# parameter: OUTPUT_FOUND_WOLFSSL_DIRECTORY contains root of source code, otherwise blank
|
|
#
|
|
#
|
|
|
|
+# Example usage:
|
|
|
|
+# FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT)
|
|
|
|
+# *********************************************************************************************
|
|
function(FIND_WOLFSSL_DIRECTORY OUTPUT_FOUND_WOLFSSL_DIRECTORY)
|
|
function(FIND_WOLFSSL_DIRECTORY OUTPUT_FOUND_WOLFSSL_DIRECTORY)
|
|
- message(STATUS "Starting FIND_WOLFSSL_DIRECTORY")
|
|
|
|
- set(CURRENT_SEARCH_DIR "$ENV{WOLFSSL_ROOT}")
|
|
|
|
- if( "${CURRENT_SEARCH_DIR}" STREQUAL "" )
|
|
|
|
- message(STATUS "The WOLFSSL_ROOT environment variable is not set. Searching...")
|
|
|
|
|
|
+ message(STATUS "Starting FIND_WOLFSSL_DIRECTORY: ${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}")
|
|
|
|
+
|
|
|
|
+ if ( "${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}" STREQUAL "" )
|
|
|
|
+ set(CURRENT_SEARCH_DIR "$ENV{WOLFSSL_ROOT}")
|
|
|
|
+ if( "${CURRENT_SEARCH_DIR}" STREQUAL "" )
|
|
|
|
+ message(STATUS "The WOLFSSL_ROOT environment variable is not set. Searching...")
|
|
|
|
+ else()
|
|
|
|
+ get_filename_component(CURRENT_SEARCH_DIR "$ENV{WOLFSSL_ROOT}" ABSOLUTE)
|
|
|
|
+ IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR}" FOUND_WOLFSSL)
|
|
|
|
+ if( FOUND_WOLFSSL )
|
|
|
|
+ message(STATUS "Found WOLFSSL_ROOT via Environment Variable:")
|
|
|
|
+ else()
|
|
|
|
+ message(FATAL_ERROR "WOLFSSL_ROOT Environment Variable defined, but path not found:")
|
|
|
|
+ message(STATUS "$ENV{WOLFSSL_ROOT}")
|
|
|
|
+ endif()
|
|
|
|
+ endif()
|
|
else()
|
|
else()
|
|
- get_filename_component(CURRENT_SEARCH_DIR "$ENV{WOLFSSL_ROOT}" ABSOLUTE)
|
|
|
|
|
|
+ get_filename_component(CURRENT_SEARCH_DIR "${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}" ABSOLUTE)
|
|
IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR}" FOUND_WOLFSSL)
|
|
IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR}" FOUND_WOLFSSL)
|
|
if( FOUND_WOLFSSL )
|
|
if( FOUND_WOLFSSL )
|
|
- message(STATUS "Found WOLFSSL_ROOT via Environment Variable: ${CURRENT_SEARCH_DIR}")
|
|
|
|
- set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR} PARENT_SCOPE)
|
|
|
|
- return()
|
|
|
|
|
|
+ message(STATUS "Found WOLFSSL_ROOT via prior specification.")
|
|
else()
|
|
else()
|
|
- message(FATAL_ERROR "WOLFSSL_ROOT Environment Variable defined, but path not found:")
|
|
|
|
- message(STATUS "$ENV{WOLFSSL_ROOT}")
|
|
|
|
|
|
+ message(FATAL_ERROR "WOLFSSL_ROOT Variable defined, but path not found: ${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}")
|
|
endif()
|
|
endif()
|
|
endif()
|
|
endif()
|
|
|
|
|
|
|
|
+
|
|
# we'll start in the CMAKE_CURRENT_SOURCE_DIR, typically [something]/projectname/components/wolfssl
|
|
# we'll start in the CMAKE_CURRENT_SOURCE_DIR, typically [something]/projectname/components/wolfssl
|
|
message(STATUS "CMAKE_CURRENT_SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR}")
|
|
message(STATUS "CMAKE_CURRENT_SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR}")
|
|
get_filename_component(CURRENT_SEARCH_DIR "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE)
|
|
get_filename_component(CURRENT_SEARCH_DIR "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE)
|
|
@@ -109,16 +207,47 @@ function(FIND_WOLFSSL_DIRECTORY OUTPUT_FOUND_WOLFSSL_DIRECTORY)
|
|
return()
|
|
return()
|
|
endif()
|
|
endif()
|
|
|
|
|
|
|
|
+ # Maintain CURRENT_SEARCH_DIR, but check various suffixes with CURRENT_SEARCH_DIR_ALT
|
|
if( THIS_USER )
|
|
if( THIS_USER )
|
|
# Check for "wolfssl-[username]" subdirectory as we recurse up the directory tree
|
|
# Check for "wolfssl-[username]" subdirectory as we recurse up the directory tree
|
|
set(CURRENT_SEARCH_DIR_ALT ${CURRENT_SEARCH_DIR}/wolfssl-${THIS_USER})
|
|
set(CURRENT_SEARCH_DIR_ALT ${CURRENT_SEARCH_DIR}/wolfssl-${THIS_USER})
|
|
- message(STATUS "Looking in ${CURRENT_SEARCH_DIR}")
|
|
|
|
|
|
+ message(STATUS "Looking in ${CURRENT_SEARCH_DIR_ALT}")
|
|
|
|
+
|
|
|
|
+ IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR_ALT}" FOUND_WOLFSSL )
|
|
|
|
+ if ( FOUND_WOLFSSL )
|
|
|
|
+ message(STATUS "Found wolfssl in user-suffix CURRENT_SEARCH_DIR_ALT = ${CURRENT_SEARCH_DIR_ALT}")
|
|
|
|
+ set(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR_ALT}")
|
|
|
|
+ set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR} PARENT_SCOPE)
|
|
|
|
+ return()
|
|
|
|
+ endif()
|
|
|
|
+ endif()
|
|
|
|
+
|
|
|
|
+ if ( FOUND_WOLFSSL )
|
|
|
|
+ # if we already found the source, skip attempt of "wolfssl-master"
|
|
|
|
+ else()
|
|
|
|
+ set(CURRENT_SEARCH_DIR_ALT ${CURRENT_SEARCH_DIR}/wolfssl-master)
|
|
|
|
+ message(STATUS "Looking in ${CURRENT_SEARCH_DIR_ALT}")
|
|
|
|
|
|
- #if(EXISTS ${CURRENT_SEARCH_DIR_ALT} AND IS_DIRECTORY ${CURRENT_SEARCH_DIR_ALT} AND EXISTS "${CURRENT_SEARCH_DIR_ALT}/wolfcrypt/src")
|
|
|
|
IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR_ALT}" FOUND_WOLFSSL )
|
|
IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR_ALT}" FOUND_WOLFSSL )
|
|
if ( FOUND_WOLFSSL )
|
|
if ( FOUND_WOLFSSL )
|
|
- message(STATUS "Found wolfssl in user-suffix CURRENT_SEARCH_DIR_ALT = ${CURRENT_SEARCH_DIR_ALT}")
|
|
|
|
- set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR_ALT} PARENT_SCOPE)
|
|
|
|
|
|
+ message(STATUS "Found wolfssl in master-suffix CURRENT_SEARCH_DIR_ALT = ${CURRENT_SEARCH_DIR_ALT}")
|
|
|
|
+ set(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR_ALT}")
|
|
|
|
+ set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR} PARENT_SCOPE)
|
|
|
|
+ return()
|
|
|
|
+ endif()
|
|
|
|
+ endif()
|
|
|
|
+
|
|
|
|
+ if ( FOUND_WOLFSSL )
|
|
|
|
+ # if we already found the source, skip attempt of "wolfssl"
|
|
|
|
+ else()
|
|
|
|
+ set(CURRENT_SEARCH_DIR_ALT ${CURRENT_SEARCH_DIR}/wolfssl)
|
|
|
|
+ message(STATUS "Looking in ${CURRENT_SEARCH_DIR_ALT}")
|
|
|
|
+
|
|
|
|
+ IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR_ALT}" FOUND_WOLFSSL )
|
|
|
|
+ if ( FOUND_WOLFSSL )
|
|
|
|
+ message(STATUS "Found wolfssl in CURRENT_SEARCH_DIR_ALT = ${CURRENT_SEARCH_DIR_ALT}")
|
|
|
|
+ set(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR_ALT}")
|
|
|
|
+ set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR} PARENT_SCOPE)
|
|
return()
|
|
return()
|
|
endif()
|
|
endif()
|
|
endif()
|
|
endif()
|
|
@@ -138,7 +267,8 @@ function(FIND_WOLFSSL_DIRECTORY OUTPUT_FOUND_WOLFSSL_DIRECTORY)
|
|
get_filename_component(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR}" DIRECTORY)
|
|
get_filename_component(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR}" DIRECTORY)
|
|
message(STATUS "Next CURRENT_SEARCH_DIR = ${CURRENT_SEARCH_DIR}")
|
|
message(STATUS "Next CURRENT_SEARCH_DIR = ${CURRENT_SEARCH_DIR}")
|
|
if( "${PRIOR_SEARCH_DIR}" STREQUAL "${CURRENT_SEARCH_DIR}" )
|
|
if( "${PRIOR_SEARCH_DIR}" STREQUAL "${CURRENT_SEARCH_DIR}" )
|
|
- # when the search directory is empty, we'll give up
|
|
|
|
|
|
+ # When the parent is current directory, cannot go any further. We didn't find wolfssl.
|
|
|
|
+ # When the search directory is empty, we'll give up.
|
|
set(CURRENT_SEARCH_DIR "")
|
|
set(CURRENT_SEARCH_DIR "")
|
|
endif()
|
|
endif()
|
|
endwhile()
|
|
endwhile()
|
|
@@ -149,17 +279,47 @@ endfunction()
|
|
|
|
|
|
|
|
|
|
# Example usage:
|
|
# Example usage:
|
|
|
|
+#
|
|
|
|
+# Simply find the WOLFSSL_DIRECTORY by searching parent directories:
|
|
|
|
+# FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT)
|
|
|
|
+#
|
|
|
|
|
|
|
|
+message(STATUS "CONFIG_TARGET_PLATFORM = ${CONFIG_TARGET_PLATFORM}")
|
|
|
|
|
|
|
|
+if (0)
|
|
|
|
+ get_cmake_property(_variableNames VARIABLES)
|
|
|
|
+ list (SORT _variableNames)
|
|
|
|
+ message(STATUS "")
|
|
|
|
+ message(STATUS "ALL VARIABLES BEGIN")
|
|
|
|
+ message(STATUS "")
|
|
|
|
+ foreach (_variableName ${_variableNames})
|
|
|
|
+ message(STATUS "${_variableName}=${${_variableName}}")
|
|
|
|
+ endforeach()
|
|
|
|
+ message(STATUS "")
|
|
|
|
+ message(STATUS "ALL VARIABLES END")
|
|
|
|
+ message(STATUS "")
|
|
|
|
+endif()
|
|
|
|
|
|
|
|
+if ( ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") OR ("${IDF_TARGET}" STREQUAL "esp8266") )
|
|
|
|
+ # There's no esp_timer, no driver components for the ESP8266
|
|
|
|
+ message(STATUS "Early expansion EXCLUDES esp_timer: ${THIS_INCLUDE_TIMER}")
|
|
|
|
+ message(STATUS "Early expansion EXCLUDES driver: ${THIS_INCLUDE_DRIVER}")
|
|
|
|
+ set(THIS_INCLUDE_TIMER "")
|
|
|
|
+ set(THIS_INCLUDE_DRIVER "")
|
|
|
|
+else()
|
|
|
|
+ message(STATUS "Early expansion includes esp_timer: ${THIS_INCLUDE_TIMER}")
|
|
|
|
+ message(STATUS "Early expansion includes driver: ${THIS_INCLUDE_DRIVER}")
|
|
|
|
+ set(THIS_INCLUDE_TIMER "esp_timer")
|
|
|
|
+ set(THIS_INCLUDE_DRIVER "driver")
|
|
|
|
+endif()
|
|
|
|
|
|
if(CMAKE_BUILD_EARLY_EXPANSION)
|
|
if(CMAKE_BUILD_EARLY_EXPANSION)
|
|
message(STATUS "wolfssl component CMAKE_BUILD_EARLY_EXPANSION:")
|
|
message(STATUS "wolfssl component CMAKE_BUILD_EARLY_EXPANSION:")
|
|
idf_component_register(
|
|
idf_component_register(
|
|
REQUIRES "${COMPONENT_REQUIRES}"
|
|
REQUIRES "${COMPONENT_REQUIRES}"
|
|
PRIV_REQUIRES # esp_hw_support
|
|
PRIV_REQUIRES # esp_hw_support
|
|
- esp_timer
|
|
|
|
- driver # this will typically only be needed for wolfSSL benchmark
|
|
|
|
|
|
+ ${THIS_INCLUDE_TIMER}
|
|
|
|
+ ${THIS_INCLUDE_DRIVER} # this will typically only be needed for wolfSSL benchmark
|
|
)
|
|
)
|
|
|
|
|
|
else()
|
|
else()
|
|
@@ -171,24 +331,52 @@ else()
|
|
# search for wolfSSL
|
|
# search for wolfSSL
|
|
FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT)
|
|
FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT)
|
|
if(WOLFSSL_ROOT)
|
|
if(WOLFSSL_ROOT)
|
|
- message(STATUS "NEW Found wolfssl directory at: ${WOLFSSL_ROOT}")
|
|
|
|
|
|
+ IS_WOLFSSL_SOURCE("${WOLFSSL_ROOT}" FOUND_WOLFSSL)
|
|
|
|
+ if(FOUND_WOLFSSL)
|
|
|
|
+ message(STATUS "Found WOLFSSL_ROOT via CMake specification.")
|
|
|
|
+ else()
|
|
|
|
+ # WOLFSSL_ROOT Path specified in CMakeLists.txt is not a valid path
|
|
|
|
+ message(FATAL_ERROR "WOLFSSL_ROOT CMake Variable defined, but path not found: ${WOLFSSL_ROOT}\n"
|
|
|
|
+ "Try correcting WOLFSSL_ROOT in your project CMakeFile.txt or setting environment variable.")
|
|
|
|
+ # Abort CMake after fatal error.
|
|
|
|
+ endif()
|
|
else()
|
|
else()
|
|
- message(STATUS "NEW wolfssl directory not found.")
|
|
|
|
|
|
+ message(STATUS "Searching for wolfSL source code...")
|
|
|
|
+ FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT)
|
|
|
|
+ endif()
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(WOLFSSL_ROOT)
|
|
|
|
+ message(STATUS "Confirmed wolfssl directory at: ${WOLFSSL_ROOT}")
|
|
|
|
+ else()
|
|
|
|
+ message(STATUS "Failed: wolfssl directory not found.")
|
|
# Abort. We need wolfssl _somewhere_.
|
|
# Abort. We need wolfssl _somewhere_.
|
|
- message(FATAL_ERROR "Could not find wolfssl in ${WOLFSSL_ROOT}.\n"
|
|
|
|
- "Try setting WOLFSSL_ROOT environment variable or git clone.")
|
|
|
|
|
|
+ message(FATAL_ERROR "Could not find wolfssl in any parent directory named wolfssl-${THIS_USER}, wolfssl-master, or wolfssl.\n"
|
|
|
|
+ "Try setting WOLFSSL_ROOT environment variable, cmake variable in project, copy source, or use managed components.")
|
|
|
|
+ # Abort CMake after fatal error.
|
|
endif()
|
|
endif()
|
|
|
|
|
|
set(INCLUDE_PATH ${WOLFSSL_ROOT})
|
|
set(INCLUDE_PATH ${WOLFSSL_ROOT})
|
|
|
|
|
|
set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/src/")
|
|
set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/src/")
|
|
|
|
|
|
- if( ${CMAKE_PROJECT_NAME} STREQUAL "wolfssl_benchmark" )
|
|
|
|
- set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/benchmark")
|
|
|
|
- endif()
|
|
|
|
|
|
+ # During regression tests, optionally copy source locally and use: set(USE_LOCAL_TEST_BENCH 1)
|
|
|
|
+ set(USE_LOCAL_TEST_BENCH 0)
|
|
|
|
+ if(NOT USE_LOCAL_TEST_BENCH)
|
|
|
|
+ if( "${CMAKE_PROJECT_NAME}" STREQUAL "hello-world" )
|
|
|
|
+ message(STATUS "Include ${WOLFSSL_ROOT}/wolfcrypt/benchmark")
|
|
|
|
+ set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/benchmark")
|
|
|
|
+ endif()
|
|
|
|
+
|
|
|
|
+ if( "${CMAKE_PROJECT_NAME}" STREQUAL "wolfssl_benchmark" )
|
|
|
|
+ message(STATUS "Include ${WOLFSSL_ROOT}/wolfcrypt/benchmark")
|
|
|
|
+ set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/benchmark")
|
|
|
|
+ endif()
|
|
|
|
|
|
- if( ${CMAKE_PROJECT_NAME} STREQUAL "wolfssl_test" )
|
|
|
|
- set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/test")
|
|
|
|
|
|
+ if( "${CMAKE_PROJECT_NAME}" STREQUAL "wolfssl_test" )
|
|
|
|
+ message(STATUS "Include ${WOLFSSL_ROOT}/wolfcrypt/test")
|
|
|
|
+ set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/test")
|
|
|
|
+ endif()
|
|
endif()
|
|
endif()
|
|
|
|
|
|
set(COMPONENT_SRCDIRS "\"${WOLFSSL_ROOT}/src/\""
|
|
set(COMPONENT_SRCDIRS "\"${WOLFSSL_ROOT}/src/\""
|
|
@@ -200,16 +388,19 @@ else()
|
|
|
|
|
|
message(STATUS "This COMPONENT_SRCDIRS = ${COMPONENT_SRCDIRS}")
|
|
message(STATUS "This COMPONENT_SRCDIRS = ${COMPONENT_SRCDIRS}")
|
|
|
|
|
|
|
|
+ # wolfSSL user_settings.h is in the local project.
|
|
set(WOLFSSL_PROJECT_DIR "${CMAKE_HOME_DIRECTORY}/components/wolfssl")
|
|
set(WOLFSSL_PROJECT_DIR "${CMAKE_HOME_DIRECTORY}/components/wolfssl")
|
|
- add_definitions(-DWOLFSSL_USER_SETTINGS_DIR="${WOLFSSL_PROJECT_DIR}/include/user_settings.h")
|
|
|
|
|
|
+ # add_definitions(-DWOLFSSL_USER_SETTINGS_DIR="${WOLFSSL_PROJECT_DIR}/include/user_settings.h")
|
|
|
|
|
|
|
|
+ string(REPLACE "/" "//" STR_WOLFSSL_PROJECT_DIR "${WOLFSSL_PROJECT_DIR}")
|
|
|
|
+ add_definitions(-DWOLFSSL_USER_SETTINGS_DIR="${STR_WOLFSSL_PROJECT_DIR}//include//user_settings.h")
|
|
|
|
|
|
# Espressif may take several passes through this makefile. Check to see if we found IDF
|
|
# Espressif may take several passes through this makefile. Check to see if we found IDF
|
|
string(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "" WOLFSSL_FOUND_IDF)
|
|
string(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "" WOLFSSL_FOUND_IDF)
|
|
|
|
|
|
# get a list of all wolfcrypt assembly files; we'll exclude them as they don't target Xtensa
|
|
# get a list of all wolfcrypt assembly files; we'll exclude them as they don't target Xtensa
|
|
file(GLOB EXCLUDE_ASM *.S)
|
|
file(GLOB EXCLUDE_ASM *.S)
|
|
- file(GLOB_RECURSE EXCLUDE_ASM ${CMAKE_SOURCE_DIR} "${WOLFSSL_ROOT}/wolfcrypt/src/*.S")
|
|
|
|
|
|
+ file(GLOB EXCLUDE_ASM ${CMAKE_SOURCE_DIR} "${WOLFSSL_ROOT}/wolfcrypt/src/*.S")
|
|
|
|
|
|
message(STATUS "IDF_PATH = $ENV{IDF_PATH}")
|
|
message(STATUS "IDF_PATH = $ENV{IDF_PATH}")
|
|
message(STATUS "PROJECT_SOURCE_DIR = ${PROJECT_SOURCE_DIR}")
|
|
message(STATUS "PROJECT_SOURCE_DIR = ${PROJECT_SOURCE_DIR}")
|
|
@@ -232,11 +423,13 @@ else()
|
|
message(STATUS "Remove either the local project component: ${WOLFSSL_PROJECT_DIR} ")
|
|
message(STATUS "Remove either the local project component: ${WOLFSSL_PROJECT_DIR} ")
|
|
message(STATUS "or the Espressif shared component installed at: $ENV{IDF_PATH}/components/wolfssl/ ")
|
|
message(STATUS "or the Espressif shared component installed at: $ENV{IDF_PATH}/components/wolfssl/ ")
|
|
message(STATUS "")
|
|
message(STATUS "")
|
|
- message(FATAL_ERROR "Please use wolfSSL in either local project or Espressif components, but not both.")
|
|
|
|
message(STATUS "")
|
|
message(STATUS "")
|
|
message(STATUS "**************************************************************************************")
|
|
message(STATUS "**************************************************************************************")
|
|
message(STATUS "")
|
|
message(STATUS "")
|
|
|
|
|
|
|
|
+ message(FATAL_ERROR "Please use wolfSSL in either local project or Espressif components, but not both.")
|
|
|
|
+ # Abort CMake after fatal error.
|
|
|
|
+
|
|
# Optional: if you change the above FATAL_ERROR to STATUS you can warn at runtime with this macro definition:
|
|
# Optional: if you change the above FATAL_ERROR to STATUS you can warn at runtime with this macro definition:
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_MULTI_INSTALL_WARNING")
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_MULTI_INSTALL_WARNING")
|
|
|
|
|
|
@@ -286,6 +479,7 @@ else()
|
|
message(FATAL_ERROR "Found stray wolfSSL user_settings.h in "
|
|
message(FATAL_ERROR "Found stray wolfSSL user_settings.h in "
|
|
"${WOLFSSL_ROOT}/include/user_settings.h "
|
|
"${WOLFSSL_ROOT}/include/user_settings.h "
|
|
" (please move it to ${WOLFSSL_PROJECT_DIR}/include/user_settings.h )")
|
|
" (please move it to ${WOLFSSL_PROJECT_DIR}/include/user_settings.h )")
|
|
|
|
+ # Abort CMake after fatal error.
|
|
else()
|
|
else()
|
|
# we won't overwrite an existing user settings file, just note that we already have one:
|
|
# we won't overwrite an existing user settings file, just note that we already have one:
|
|
if( EXISTS "${WOLFSSL_PROJECT_DIR}/include/user_settings.h" )
|
|
if( EXISTS "${WOLFSSL_PROJECT_DIR}/include/user_settings.h" )
|
|
@@ -355,17 +549,22 @@ else()
|
|
message(STATUS "Could not find RTOS path")
|
|
message(STATUS "Could not find RTOS path")
|
|
endif()
|
|
endif()
|
|
endif()
|
|
endif()
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ message(STATUS "THIS_IDF_PATH = $THIS_IDF_PATH")
|
|
|
|
+ # wolfSSL-specific include directories
|
|
set(COMPONENT_ADD_INCLUDEDIRS
|
|
set(COMPONENT_ADD_INCLUDEDIRS
|
|
"./include" # this is the location of wolfssl user_settings.h
|
|
"./include" # this is the location of wolfssl user_settings.h
|
|
"\"${WOLFSSL_ROOT}/\""
|
|
"\"${WOLFSSL_ROOT}/\""
|
|
"\"${WOLFSSL_ROOT}/wolfssl/\""
|
|
"\"${WOLFSSL_ROOT}/wolfssl/\""
|
|
"\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/\""
|
|
"\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/\""
|
|
|
|
+ "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/port/Espressif\""
|
|
"\"${RTOS_IDF_PATH}/\""
|
|
"\"${RTOS_IDF_PATH}/\""
|
|
|
|
+ # wolfSSL release after v5.7 includes WiFi, time, and mem/debug helpers
|
|
|
|
+ "${THIS_IDF_PATH}/components/esp_event/include"
|
|
|
|
+ "${THIS_IDF_PATH}/components/esp_netif/include"
|
|
|
|
+ "${THIS_IDF_PATH}/components/esp_wifi/include"
|
|
)
|
|
)
|
|
|
|
|
|
-
|
|
|
|
|
|
+ # Optionally include cryptoauthlib if present
|
|
if(IS_DIRECTORY ${IDF_PATH}/components/cryptoauthlib)
|
|
if(IS_DIRECTORY ${IDF_PATH}/components/cryptoauthlib)
|
|
list(APPEND COMPONENT_ADD_INCLUDEDIRS "../cryptoauthlib/lib")
|
|
list(APPEND COMPONENT_ADD_INCLUDEDIRS "../cryptoauthlib/lib")
|
|
endif()
|
|
endif()
|
|
@@ -374,7 +573,7 @@ else()
|
|
list(APPEND COMPONENT_ADD_INCLUDEDIRS "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/\"")
|
|
list(APPEND COMPONENT_ADD_INCLUDEDIRS "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/\"")
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
+ # Some files are known to be included elsewhere, or not used for Espressif
|
|
set(COMPONENT_SRCEXCLUDE
|
|
set(COMPONENT_SRCEXCLUDE
|
|
"\"${WOLFSSL_ROOT}/src/bio.c\""
|
|
"\"${WOLFSSL_ROOT}/src/bio.c\""
|
|
"\"${WOLFSSL_ROOT}/src/conf.c\""
|
|
"\"${WOLFSSL_ROOT}/src/conf.c\""
|
|
@@ -387,6 +586,8 @@ else()
|
|
"\"${WOLFSSL_ROOT}/src/ssl_misc.c\"" # included by ssl.c
|
|
"\"${WOLFSSL_ROOT}/src/ssl_misc.c\"" # included by ssl.c
|
|
"\"${WOLFSSL_ROOT}/src/x509.c\""
|
|
"\"${WOLFSSL_ROOT}/src/x509.c\""
|
|
"\"${WOLFSSL_ROOT}/src/x509_str.c\""
|
|
"\"${WOLFSSL_ROOT}/src/x509_str.c\""
|
|
|
|
+ "\"${WOLFSSL_ROOT}/wolfcrypt/src/ext_kyber.c\"" # external non-wolfssl Kyber disabled by default
|
|
|
|
+ "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/ext_kyber.h\"" # external non-wolfssl Kyber disabled by default
|
|
"\"${WOLFSSL_ROOT}/wolfcrypt/src/evp.c\""
|
|
"\"${WOLFSSL_ROOT}/wolfcrypt/src/evp.c\""
|
|
"\"${WOLFSSL_ROOT}/wolfcrypt/src/misc.c\""
|
|
"\"${WOLFSSL_ROOT}/wolfcrypt/src/misc.c\""
|
|
"\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_arm32.c\""
|
|
"\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_arm32.c\""
|
|
@@ -423,17 +624,34 @@ else()
|
|
INCLUDE_DIRS "${COMPONENT_ADD_INCLUDEDIRS}"
|
|
INCLUDE_DIRS "${COMPONENT_ADD_INCLUDEDIRS}"
|
|
REQUIRES "${COMPONENT_REQUIRES}"
|
|
REQUIRES "${COMPONENT_REQUIRES}"
|
|
EXCLUDE_SRCS "${COMPONENT_SRCEXCLUDE}"
|
|
EXCLUDE_SRCS "${COMPONENT_SRCEXCLUDE}"
|
|
- PRIV_REQUIRES esp_timer driver # this will typically only be needed for wolfSSL benchmark
|
|
|
|
|
|
+ PRIV_REQUIRES
|
|
|
|
+ "${THIS_INCLUDE_TIMER}"
|
|
|
|
+ "${THIS_INCLUDE_DRIVER}" # this will typically only be needed for wolfSSL benchmark
|
|
)
|
|
)
|
|
- # some optional diagnostics
|
|
|
|
- if (1)
|
|
|
|
|
|
+
|
|
|
|
+ # Some optional diagnostics. Verbose ones are truncated.
|
|
|
|
+ if (VERBOSE_COMPONENT_MESSAGES)
|
|
get_cmake_property(_variableNames VARIABLES)
|
|
get_cmake_property(_variableNames VARIABLES)
|
|
list (SORT _variableNames)
|
|
list (SORT _variableNames)
|
|
message(STATUS "")
|
|
message(STATUS "")
|
|
message(STATUS "ALL VARIABLES BEGIN")
|
|
message(STATUS "ALL VARIABLES BEGIN")
|
|
message(STATUS "")
|
|
message(STATUS "")
|
|
foreach (_variableName ${_variableNames})
|
|
foreach (_variableName ${_variableNames})
|
|
- message(STATUS "${_variableName}=${${_variableName}}")
|
|
|
|
|
|
+ if ( ("${_variableName}" STREQUAL "bootloader_binary_files")
|
|
|
|
+ OR ("${_variableName}" STREQUAL "Component paths")
|
|
|
|
+ OR ("${_variableName}" STREQUAL "component_targets")
|
|
|
|
+ OR ("${_variableName}" STREQUAL "__COMPONENT_TARGETS")
|
|
|
|
+ OR ("${_variableName}" STREQUAL "CONFIGS_LIST")
|
|
|
|
+ OR ("${_variableName}" STREQUAL "__CONFIG_VARIABLES")
|
|
|
|
+ OR ("${_variableName}" STREQUAL "val")
|
|
|
|
+ OR ("${_variableName}" MATCHES "^__idf_")
|
|
|
|
+ )
|
|
|
|
+ # Truncate the displayed value:
|
|
|
|
+ string(SUBSTRING "${${_variableName}}" 0 70 truncatedValue)
|
|
|
|
+ message(STATUS "${_variableName} = ${truncatedValue} ... (truncated)")
|
|
|
|
+ else()
|
|
|
|
+ message(STATUS "${_variableName}=${${_variableName}}")
|
|
|
|
+ endif()
|
|
endforeach()
|
|
endforeach()
|
|
message(STATUS "")
|
|
message(STATUS "")
|
|
message(STATUS "ALL VARIABLES END")
|
|
message(STATUS "ALL VARIABLES END")
|
|
@@ -520,6 +738,8 @@ if(NOT CMAKE_BUILD_EARLY_EXPANSION)
|
|
execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "show" "--no-patch" "--no-notes" "--pretty=\'\%cd\'" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES )
|
|
execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "show" "--no-patch" "--no-notes" "--pretty=\'\%cd\'" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES )
|
|
LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH_DATE "${TMP_OUT}" "${TMP_RES}")
|
|
LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH_DATE "${TMP_OUT}" "${TMP_RES}")
|
|
|
|
|
|
|
|
+ LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_WOLFSSL_ROOT "${WOLFSSL_ROOT}" "${TMP_RES}")
|
|
|
|
+
|
|
message(STATUS "************************************************************************************************")
|
|
message(STATUS "************************************************************************************************")
|
|
message(STATUS "wolfssl component config complete!")
|
|
message(STATUS "wolfssl component config complete!")
|
|
message(STATUS "************************************************************************************************")
|
|
message(STATUS "************************************************************************************************")
|