|
| 1 | +# wolfTPM 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 | + |
| 8 | +# The wolfTPM CMake file should be able to find the source code. |
| 9 | +# Otherwise, assign an environment variable or set it here: |
| 10 | +# |
| 11 | +# set(WOLFTPM_ROOT "~/workspace/wolftpm-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 | + |
| 50 | +# Check that there are no conflicting wolfSSL components. |
| 51 | +# |
| 52 | +# The ESP Registry Component will be in ./managed_components/wolfssl__wolfssl |
| 53 | +# The local component wolfSSL directory will be in ./components/wolfssl |
| 54 | +if( EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" AND EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl" ) |
| 55 | + # These exclude statements don't seem to be honored by the $ENV{IDF_PATH}/tools/cmake/project.cmake' |
| 56 | + # add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" EXCLUDE_FROM_ALL) |
| 57 | + # add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl/include" EXCLUDE_FROM_ALL) |
| 58 | + # So we'll error out and let the user decide how to proceed: |
| 59 | + message(WARNING "\nFound wolfSSL components in\n" |
| 60 | + "./managed_components/wolfssl__wolfssl\n" |
| 61 | + "and\n" |
| 62 | + "./components/wolfssl\n" |
| 63 | + "in project directory: \n" |
| 64 | + "${CMAKE_HOME_DIRECTORY}") |
| 65 | + message(FATAL_ERROR "\nPlease use either the ESP Registry Managed Component or the wolfSSL component directory but not both.\n" |
| 66 | + "If removing the ./managed_components/wolfssl__wolfssl directory, remember to also remove " |
| 67 | + "or rename the idf_component.yml file typically found in ./main/") |
| 68 | +else() |
| 69 | + message(STATUS "No conflicting wolfSSL components found.") |
| 70 | +endif() |
| 71 | + |
| 72 | +# Check that there are no conflicting wolfTPM components. |
| 73 | +# |
| 74 | +# The ESP Registry Component will be in ./managed_components/wolfssl__wolftpm |
| 75 | +# The local component wolfTPM directory will be in ./components/wolftpm |
| 76 | +if( EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolftpm" AND EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolftpm" ) |
| 77 | + # These exclude statements don't seem to be honored by the $ENV{IDF_PATH}/tools/cmake/project.cmake' |
| 78 | + # add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolftpm" EXCLUDE_FROM_ALL) |
| 79 | + # add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolftpm/include" EXCLUDE_FROM_ALL) |
| 80 | + # So we'll error out and let the user decide how to proceed: |
| 81 | + message(WARNING "\nFound wolfTPM components in\n" |
| 82 | + "./managed_components/wolfssl__wolftpm\n" |
| 83 | + "and\n" |
| 84 | + "./components/wolftpm\n" |
| 85 | + "in project directory: \n" |
| 86 | + "${CMAKE_HOME_DIRECTORY}") |
| 87 | + message(FATAL_ERROR "\nPlease use either the ESP Registry Managed Component or the wolfTPM component directory but not both.\n" |
| 88 | + "If removing the ./managed_components/wolfssl__wolftpm directory, remember to also remove " |
| 89 | + "or rename the idf_component.yml file typically found in ./main/") |
| 90 | +else() |
| 91 | + message(STATUS "No conflicting wolfTPM components found.") |
| 92 | +endif() |
| 93 | + |
| 94 | +include($ENV{IDF_PATH}/tools/cmake/project.cmake) |
| 95 | + |
| 96 | +project(wolfTPM_test) |
0 commit comments