Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 1 | From b22daa35b3ef912e44e7f6a8d9f24c4703fb4784 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 |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 4 | Subject: [PATCH 1/1] Add capability to selectively build libraries |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 5 | |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 6 | Introduce the BUILD_X509 and BUILD_TLS options which allows disabling |
| 7 | or enabling building of these libraries. |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 8 | |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 9 | Uptream-status: Invalid [other] |
| 10 | - This is a Trusted Services specific change, there is no intention |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 11 | to upstream this change. |
| 12 | |
| 13 | Signed-off-by: Gyorgy Szing <Gyorgy.Szing@arm.com> |
| 14 | --- |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 15 | library/CMakeLists.txt | 77 +++++++++++++++++++++++++++++++----------- |
| 16 | 1 file changed, 57 insertions(+), 20 deletions(-) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 17 | |
| 18 | diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 19 | index 535988303..ea1247427 100644 |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 20 | --- a/library/CMakeLists.txt |
| 21 | +++ b/library/CMakeLists.txt |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 22 | @@ -2,6 +2,8 @@ option(USE_STATIC_MBEDTLS_LIBRARY "Build mbed TLS static library." ON) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 23 | option(USE_SHARED_MBEDTLS_LIBRARY "Build mbed TLS shared library." OFF) |
| 24 | option(LINK_WITH_PTHREAD "Explicitly link mbed TLS library to pthread." OFF) |
| 25 | option(LINK_WITH_TRUSTED_STORAGE "Explicitly link mbed TLS library to trusted_storage." OFF) |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 26 | +option(BUIILD_X509 "Build x509 library too." ON) |
| 27 | +option(BUILD_TLS "Build TLS library too" OFF) |
| 28 | |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 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 |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 31 | @@ -250,7 +252,15 @@ 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() |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 34 | |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 35 | -set(target_libraries ${mbedcrypto_target} ${mbedx509_target} ${mbedtls_target}) |
| 36 | +set(target_libraries ${mbedcrypto_target}) |
| 37 | + |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 38 | +if (BUIILD_X509) |
| 39 | + list(APPEND target_libraries ${mbedx509_target}) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 40 | +endif() |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 41 | + |
| 42 | +if (BUILD_TLS) |
| 43 | + list(APPEND target_libraries ${mbedtls_target}) |
| 44 | +endif() |
| 45 | |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 46 | if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY) |
| 47 | string(APPEND mbedtls_static_target "_static") |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 48 | @@ -258,9 +268,15 @@ if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 49 | string(APPEND mbedcrypto_static_target "_static") |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 50 | |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 51 | list(APPEND target_libraries |
| 52 | - ${mbedcrypto_static_target} |
Balint Dobszay | 21ce26e | 2023-05-19 10:12:49 +0200 | [diff] [blame] | 53 | - ${mbedx509_static_target} |
| 54 | - ${mbedtls_static_target}) |
| 55 | + ${mbedcrypto_static_target}) |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 56 | + |
| 57 | + if (BUIILD_X509 OR BUIILD_TLS) |
| 58 | + list(APPEND target_libraries ${mbedx509_static_target}) |
| 59 | + endif() |
Balint Dobszay | 21ce26e | 2023-05-19 10:12:49 +0200 | [diff] [blame] | 60 | + |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 61 | + if (BUILD_TLS) |
| 62 | + list(APPEND target_libraries ${mbedtls_static_target}) |
Balint Dobszay | 21ce26e | 2023-05-19 10:12:49 +0200 | [diff] [blame] | 63 | + endif() |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 64 | endif() |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 65 | |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 66 | if(USE_STATIC_MBEDTLS_LIBRARY) |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 67 | @@ -272,13 +288,17 @@ if(USE_STATIC_MBEDTLS_LIBRARY) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 68 | target_link_libraries(${mbedcrypto_static_target} PUBLIC everest) |
| 69 | endif() |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 70 | |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 71 | - add_library(${mbedx509_static_target} STATIC ${src_x509}) |
| 72 | - set_target_properties(${mbedx509_static_target} PROPERTIES OUTPUT_NAME mbedx509) |
| 73 | - target_link_libraries(${mbedx509_static_target} PUBLIC ${libs} ${mbedcrypto_static_target}) |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 74 | + if (BUIILD_X509 OR BUIILD_TLS) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 75 | + add_library(${mbedx509_static_target} STATIC ${src_x509}) |
| 76 | + set_target_properties(${mbedx509_static_target} PROPERTIES OUTPUT_NAME mbedx509) |
| 77 | + target_link_libraries(${mbedx509_static_target} PUBLIC ${libs} ${mbedcrypto_static_target}) |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 78 | + endif() |
| 79 | |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 80 | - add_library(${mbedtls_static_target} STATIC ${src_tls}) |
| 81 | - set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls) |
| 82 | - target_link_libraries(${mbedtls_static_target} PUBLIC ${libs} ${mbedx509_static_target}) |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 83 | + if (BUILD_TLS) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 84 | + add_library(${mbedtls_static_target} STATIC ${src_tls}) |
| 85 | + set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls) |
| 86 | + target_link_libraries(${mbedtls_static_target} PUBLIC ${libs} ${mbedx509_static_target}) |
| 87 | + endif() |
| 88 | endif(USE_STATIC_MBEDTLS_LIBRARY) |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 89 | |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 90 | if(USE_SHARED_MBEDTLS_LIBRARY) |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 91 | @@ -290,14 +310,16 @@ if(USE_SHARED_MBEDTLS_LIBRARY) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 92 | if(TARGET everest) |
| 93 | target_link_libraries(${mbedcrypto_target} PUBLIC everest) |
| 94 | endif() |
| 95 | - |
| 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}) |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 103 | + if (BUIILD_X509 OR BUILD_TLS) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 104 | + add_library(${mbedx509_target} SHARED ${src_x509}) |
Balint Dobszay | 21ce26e | 2023-05-19 10:12:49 +0200 | [diff] [blame] | 105 | + set_target_properties(${mbedx509_target} PROPERTIES VERSION 3.4.0 SOVERSION 5) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 106 | + target_link_libraries(${mbedx509_target} PUBLIC ${libs} ${mbedcrypto_target}) |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 107 | + endif() |
| 108 | + if (BUILD_TLS) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 109 | + add_library(${mbedtls_target} SHARED ${src_tls}) |
Balint Dobszay | 21ce26e | 2023-05-19 10:12:49 +0200 | [diff] [blame] | 110 | + set_target_properties(${mbedtls_target} PROPERTIES VERSION 3.4.0 SOVERSION 19) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 111 | + target_link_libraries(${mbedtls_target} PUBLIC ${libs} ${mbedx509_target}) |
| 112 | + endif() |
| 113 | endif(USE_SHARED_MBEDTLS_LIBRARY) |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 114 | |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 115 | foreach(target IN LISTS target_libraries) |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 116 | @@ -322,7 +344,22 @@ endforeach(target) |
| 117 | |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 118 | set(lib_target "${MBEDTLS_TARGET_PREFIX}lib") |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 119 | |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 120 | -add_custom_target(${lib_target} DEPENDS ${mbedcrypto_target} ${mbedx509_target} ${mbedtls_target}) |
| 121 | +add_custom_target(${lib_target} DEPENDS ${mbedcrypto_target}) |
| 122 | + |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 123 | +if(BUIILD_X509 OR BUIILD_TLS) |
| 124 | + add_dependencies(${lib_target} ${mbedx509_target}) |
| 125 | +endif() |
| 126 | + |
| 127 | +if(BUIILD_TLS) |
| 128 | + add_dependencies(${lib_target} ${mbedtls_target}) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 129 | +endif() |
| 130 | + |
| 131 | if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY) |
| 132 | - add_dependencies(${lib_target} ${mbedcrypto_static_target} ${mbedx509_static_target} ${mbedtls_static_target}) |
| 133 | + add_dependencies(${lib_target} ${mbedcrypto_static_target}) |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 134 | + if(BUIILD_X509 OR BUIILD_TLS) |
| 135 | + add_dependencies(${lib_target} ${mbedx509_static_target}) |
| 136 | + endif() |
| 137 | + if(BUIILD_TLS) |
| 138 | + add_dependencies(${lib_target} ${mbedtls_static_target}) |
Gyorgy Szing | 9c8daca | 2023-03-28 17:09:33 +0200 | [diff] [blame] | 139 | + endif() |
| 140 | endif() |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 141 | -- |
Balint Dobszay | 21ce26e | 2023-05-19 10:12:49 +0200 | [diff] [blame] | 142 | 2.34.1 |
Julian Hall | 29620bf | 2022-06-09 10:26:37 +0100 | [diff] [blame^] | 143 | |