Balint Dobszay | 21ce26e | 2023-05-19 10:12:49 +0200 | [diff] [blame^] | 1 | From d225c9ba98e8aafdd462bdff3f8159886a89e1d3 Mon Sep 17 00:00:00 2001 |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 2 | From: Gyorgy Szing <Gyorgy.Szing@arm.com> |
| 3 | Date: Tue, 28 Mar 2023 18:20:44 +0200 |
Balint Dobszay | 21ce26e | 2023-05-19 10:12:49 +0200 | [diff] [blame^] | 4 | Subject: [PATCH] Add capability to build libmbedcrypto only |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 5 | |
| 6 | Introduce the CRYPTO_ONLY option which configures cmake to build only |
| 7 | libmbedcrypto. |
| 8 | |
| 9 | Upstream-status: Invalid [other] |
| 10 | - This is a Trusted Services specific change, there is not intention |
| 11 | to upstream this change. |
| 12 | |
| 13 | Signed-off-by: Gyorgy Szing <Gyorgy.Szing@arm.com> |
Balint Dobszay | 21ce26e | 2023-05-19 10:12:49 +0200 | [diff] [blame^] | 14 | Signed-off-by: Balint Dobszay <balint.dobszay@arm.com> |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 15 | --- |
Balint Dobszay | 21ce26e | 2023-05-19 10:12:49 +0200 | [diff] [blame^] | 16 | library/CMakeLists.txt | 60 ++++++++++++++++++++++++++++-------------- |
| 17 | 1 file changed, 40 insertions(+), 20 deletions(-) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 18 | |
| 19 | diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt |
Balint Dobszay | 21ce26e | 2023-05-19 10:12:49 +0200 | [diff] [blame^] | 20 | index 535988303..a70848e82 100644 |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 21 | --- a/library/CMakeLists.txt |
| 22 | +++ b/library/CMakeLists.txt |
| 23 | @@ -2,6 +2,7 @@ option(USE_STATIC_MBEDTLS_LIBRARY "Build mbed TLS static library." ON) |
| 24 | option(USE_SHARED_MBEDTLS_LIBRARY "Build mbed TLS shared library." OFF) |
| 25 | option(LINK_WITH_PTHREAD "Explicitly link mbed TLS library to pthread." OFF) |
| 26 | option(LINK_WITH_TRUSTED_STORAGE "Explicitly link mbed TLS library to trusted_storage." OFF) |
Balint Dobszay | 21ce26e | 2023-05-19 10:12:49 +0200 | [diff] [blame^] | 27 | +option(CRYPTO_ONLY "Build mbedcrypto library only." On) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 28 | |
| 29 | # Set the project root directory if it's not already defined, as may happen if |
| 30 | # the library folder is included directly by a parent project, without |
Balint Dobszay | 21ce26e | 2023-05-19 10:12:49 +0200 | [diff] [blame^] | 31 | @@ -250,7 +251,11 @@ if (USE_STATIC_MBEDTLS_LIBRARY) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 32 | set(mbedcrypto_static_target ${mbedcrypto_target}) |
| 33 | endif() |
| 34 | |
| 35 | -set(target_libraries ${mbedcrypto_target} ${mbedx509_target} ${mbedtls_target}) |
| 36 | +set(target_libraries ${mbedcrypto_target}) |
| 37 | + |
| 38 | +if (NOT CRYPTO_ONLY) |
| 39 | + list(APPEND target_libraries ${mbedx509_target} ${mbedtls_target}) |
| 40 | +endif() |
| 41 | |
| 42 | if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY) |
| 43 | string(APPEND mbedtls_static_target "_static") |
Balint Dobszay | 21ce26e | 2023-05-19 10:12:49 +0200 | [diff] [blame^] | 44 | @@ -258,9 +263,13 @@ if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 45 | string(APPEND mbedcrypto_static_target "_static") |
| 46 | |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 47 | list(APPEND target_libraries |
| 48 | - ${mbedcrypto_static_target} |
Balint Dobszay | 21ce26e | 2023-05-19 10:12:49 +0200 | [diff] [blame^] | 49 | - ${mbedx509_static_target} |
| 50 | - ${mbedtls_static_target}) |
| 51 | + ${mbedcrypto_static_target}) |
| 52 | + |
| 53 | + if (NOT CRYPTO_ONLY) |
| 54 | + list(APPEND target_libraries |
| 55 | + ${mbedx509_static_target} |
| 56 | + ${mbedtls_static_target}) |
| 57 | + endif() |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 58 | endif() |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 59 | |
| 60 | if(USE_STATIC_MBEDTLS_LIBRARY) |
Balint Dobszay | 21ce26e | 2023-05-19 10:12:49 +0200 | [diff] [blame^] | 61 | @@ -272,13 +281,15 @@ if(USE_STATIC_MBEDTLS_LIBRARY) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 62 | target_link_libraries(${mbedcrypto_static_target} PUBLIC everest) |
| 63 | endif() |
| 64 | |
| 65 | - add_library(${mbedx509_static_target} STATIC ${src_x509}) |
| 66 | - set_target_properties(${mbedx509_static_target} PROPERTIES OUTPUT_NAME mbedx509) |
| 67 | - target_link_libraries(${mbedx509_static_target} PUBLIC ${libs} ${mbedcrypto_static_target}) |
| 68 | + if (NOT CRYPTO_ONLY) |
| 69 | + add_library(${mbedx509_static_target} STATIC ${src_x509}) |
| 70 | + set_target_properties(${mbedx509_static_target} PROPERTIES OUTPUT_NAME mbedx509) |
| 71 | + target_link_libraries(${mbedx509_static_target} PUBLIC ${libs} ${mbedcrypto_static_target}) |
| 72 | |
| 73 | - add_library(${mbedtls_static_target} STATIC ${src_tls}) |
| 74 | - set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls) |
| 75 | - target_link_libraries(${mbedtls_static_target} PUBLIC ${libs} ${mbedx509_static_target}) |
| 76 | + add_library(${mbedtls_static_target} STATIC ${src_tls}) |
| 77 | + set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls) |
| 78 | + target_link_libraries(${mbedtls_static_target} PUBLIC ${libs} ${mbedx509_static_target}) |
| 79 | + endif() |
| 80 | endif(USE_STATIC_MBEDTLS_LIBRARY) |
| 81 | |
| 82 | if(USE_SHARED_MBEDTLS_LIBRARY) |
Balint Dobszay | 21ce26e | 2023-05-19 10:12:49 +0200 | [diff] [blame^] | 83 | @@ -290,14 +301,15 @@ if(USE_SHARED_MBEDTLS_LIBRARY) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 84 | if(TARGET everest) |
| 85 | target_link_libraries(${mbedcrypto_target} PUBLIC everest) |
| 86 | endif() |
| 87 | - |
| 88 | - add_library(${mbedx509_target} SHARED ${src_x509}) |
Balint Dobszay | 21ce26e | 2023-05-19 10:12:49 +0200 | [diff] [blame^] | 89 | - set_target_properties(${mbedx509_target} PROPERTIES VERSION 3.4.0 SOVERSION 5) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 90 | - target_link_libraries(${mbedx509_target} PUBLIC ${libs} ${mbedcrypto_target}) |
| 91 | - |
| 92 | - add_library(${mbedtls_target} SHARED ${src_tls}) |
Balint Dobszay | 21ce26e | 2023-05-19 10:12:49 +0200 | [diff] [blame^] | 93 | - set_target_properties(${mbedtls_target} PROPERTIES VERSION 3.4.0 SOVERSION 19) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 94 | - target_link_libraries(${mbedtls_target} PUBLIC ${libs} ${mbedx509_target}) |
| 95 | + if (NOT CRYPTO_ONLY) |
| 96 | + add_library(${mbedx509_target} SHARED ${src_x509}) |
Balint Dobszay | 21ce26e | 2023-05-19 10:12:49 +0200 | [diff] [blame^] | 97 | + set_target_properties(${mbedx509_target} PROPERTIES VERSION 3.4.0 SOVERSION 5) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 98 | + target_link_libraries(${mbedx509_target} PUBLIC ${libs} ${mbedcrypto_target}) |
| 99 | + |
| 100 | + add_library(${mbedtls_target} SHARED ${src_tls}) |
Balint Dobszay | 21ce26e | 2023-05-19 10:12:49 +0200 | [diff] [blame^] | 101 | + set_target_properties(${mbedtls_target} PROPERTIES VERSION 3.4.0 SOVERSION 19) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 102 | + target_link_libraries(${mbedtls_target} PUBLIC ${libs} ${mbedx509_target}) |
| 103 | + endif() |
| 104 | endif(USE_SHARED_MBEDTLS_LIBRARY) |
| 105 | |
| 106 | foreach(target IN LISTS target_libraries) |
Balint Dobszay | 21ce26e | 2023-05-19 10:12:49 +0200 | [diff] [blame^] | 107 | @@ -322,7 +334,15 @@ endforeach(target) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 108 | |
| 109 | set(lib_target "${MBEDTLS_TARGET_PREFIX}lib") |
| 110 | |
| 111 | -add_custom_target(${lib_target} DEPENDS ${mbedcrypto_target} ${mbedx509_target} ${mbedtls_target}) |
| 112 | +add_custom_target(${lib_target} DEPENDS ${mbedcrypto_target}) |
| 113 | + |
| 114 | +if(NOT CRYPTO_ONLY) |
| 115 | + add_dependencies(${lib_target} ${mbedx509_target} ${mbedtls_target}) |
| 116 | +endif() |
| 117 | + |
| 118 | if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY) |
| 119 | - add_dependencies(${lib_target} ${mbedcrypto_static_target} ${mbedx509_static_target} ${mbedtls_static_target}) |
| 120 | + add_dependencies(${lib_target} ${mbedcrypto_static_target}) |
| 121 | + if(NOT CRYPTO_ONLY) |
| 122 | + add_dependencies(${lib_target} ${mbedx509_static_target} ${mbedtls_static_target}) |
| 123 | + endif() |
| 124 | endif() |
| 125 | -- |
Balint Dobszay | 21ce26e | 2023-05-19 10:12:49 +0200 | [diff] [blame^] | 126 | 2.34.1 |