blob: eacf0649d7e258a5699724ea1225aecaaa9c9229 [file] [log] [blame]
Raef Coles19715382020-07-10 09:50:17 +01001From 8e67edf7fa9972eb889728c38fd057d43869c2b9 Mon Sep 17 00:00:00 2001
2From: Raef Coles <raef.coles@arm.com>
3Date: Mon, 15 Jun 2020 09:43:04 +0100
4Subject: [PATCH 1/6] Allow renaming of cmake targets
5
6External projects can use this to rename the cmake targets generated to
7avoid clashes with their own targets, or targets in other external
8dependencies.
9
10Signed-off-by: Raef Coles <raef.coles@arm.com>
11---
12 library/CMakeLists.txt | 79 ++++++++++++++++++++++++++++++------------
13 1 file changed, 56 insertions(+), 23 deletions(-)
14
15diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
16index 05196e86c..fe74de25d 100644
17--- a/library/CMakeLists.txt
18+++ b/library/CMakeLists.txt
19@@ -148,16 +148,45 @@ if (NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY)
20 message(FATAL_ERROR "Need to choose static or shared mbedtls build!")
21 endif(NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY)
22
23+if(NOT DEFINED mbedtls_target)
24+ set(mbedtls_target "mbedtls")
25+ set(mbedtls_target "mbedtls" PARENT_SCOPE)
26+endif()
27+
28+if(NOT DEFINED mbedx509_target)
29+ set(mbedx509_target "mbedx509")
30+ set(mbedx509_target "mbedx509" PARENT_SCOPE)
31+endif()
32+
33+if(NOT DEFINED mbedcrypto_target)
34+ set(mbedcrypto_target "mbedcrypto")
35+ set(mbedcrypto_target "mbedcrypto" PARENT_SCOPE)
36+endif()
37+
38+if (USE_STATIC_MBEDTLS_LIBRARY)
39+ if(NOT DEFINED mbedtls_static_target)
40+ set(mbedtls_static_target ${mbedtls_target})
41+ set(mbedtls_static_target ${mbedtls_target} PARENT_SCOPE)
42+ endif()
43+
44+ if(NOT DEFINED mbedx509_static_target)
45+ set(mbedx509_static_target ${mbedx509_target})
46+ set(mbedx509_static_target ${mbedx509_target} PARENT_SCOPE)
47+ endif()
48+
49+ if(NOT DEFINED mbedcrypto_static_target)
50+ set(mbedcrypto_static_target ${mbedcrypto_target})
51+ set(mbedcrypto_static_target ${mbedcrypto_target} PARENT_SCOPE)
52+ endif()
53+endif()
54+
55 if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY)
56- set(mbedtls_static_target "mbedtls_static")
57- set(mbedx509_static_target "mbedx509_static")
58- set(mbedcrypto_static_target "mbedcrypto_static")
59-elseif(USE_STATIC_MBEDTLS_LIBRARY)
60- set(mbedtls_static_target "mbedtls")
61- set(mbedx509_static_target "mbedx509")
62- set(mbedcrypto_static_target "mbedcrypto")
63+ string(APPEND mbedtls_static_target "_static")
64+ string(APPEND mbedx509_static_target "_static")
65+ string(APPEND mbedcrypto_static_target "_static")
66 endif()
67
68+
69 if(USE_STATIC_MBEDTLS_LIBRARY)
70 add_library(${mbedcrypto_static_target} STATIC ${src_crypto})
71 set_target_properties(${mbedcrypto_static_target} PROPERTIES OUTPUT_NAME mbedcrypto)
72@@ -180,30 +209,34 @@ endif(USE_STATIC_MBEDTLS_LIBRARY)
73
74 if(USE_SHARED_MBEDTLS_LIBRARY)
75
76- add_library(mbedcrypto SHARED ${src_crypto})
77- set_target_properties(mbedcrypto PROPERTIES VERSION 2.23.0 SOVERSION 5)
78- target_link_libraries(mbedcrypto ${libs})
79- target_include_directories(mbedcrypto
80+ add_library(${mbedcrypto_target} SHARED ${src_crypto})
81+ set_target_properties(${mbedcrypto_target} PROPERTIES VERSION 2.23.0 SOVERSION 5)
82+ target_link_libraries(${mbedcrypto_target} ${libs})
83+ target_include_directories(${mbedcrypto_target}
84 PUBLIC ${MBEDTLS_DIR}/include/)
85
86- add_library(mbedx509 SHARED ${src_x509})
87- set_target_properties(mbedx509 PROPERTIES VERSION 2.23.0 SOVERSION 1)
88- target_link_libraries(mbedx509 ${libs} mbedcrypto)
89- target_include_directories(mbedx509
90+ add_library(${mbedx509_target} SHARED ${src_x509})
91+ set_target_properties(${mbedx509_target} PROPERTIES VERSION 2.23.0 SOVERSION 1)
92+ target_link_libraries(${mbedx509_target} ${libs} ${mbedcrypto_target})
93+ target_include_directories(${mbedx509_target}
94 PUBLIC ${MBEDTLS_DIR}/include/)
95
96- add_library(mbedtls SHARED ${src_tls})
97- set_target_properties(mbedtls PROPERTIES VERSION 2.23.0 SOVERSION 13)
98- target_link_libraries(mbedtls ${libs} mbedx509)
99- target_include_directories(mbedtls
100- PUBLIC ${MBEDTLS_DIR}/include/)
101+ add_library(${mbedtls_target} SHARED ${src_tls})
102+ set_target_properties(${mbedtls_target} PROPERTIES VERSION 2.23.0 SOVERSION 13)
103+ target_link_libraries(${mbedtls_target} ${libs} ${mbedx509_target})
104+ target_include_directories(${mbedtls_target}
105+ PUBLIC ${${mbedtls_target}_DIR}/include/)
106
107- install(TARGETS mbedtls mbedx509 mbedcrypto
108+ install(TARGETS ${mbedtls_target} ${mbedx509_target} ${mbedcrypto_target}
109 DESTINATION ${LIB_INSTALL_DIR}
110 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
111 endif(USE_SHARED_MBEDTLS_LIBRARY)
112
113-add_custom_target(lib DEPENDS mbedcrypto mbedx509 mbedtls)
114+if(NOT DEFINED lib_target)
115+ set(lib_target lib)
116+endif()
117+
118+add_custom_target(${lib_target} DEPENDS ${mbedcrypto_target} ${mbedx509_target} ${mbedtls_target})
119 if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY)
120- add_dependencies(lib mbedcrypto_static mbedx509_static mbedtls_static)
121+ add_dependencies(${lib_target} ${mbedcrypto_static_target} ${mbedx509_static_target} ${mbedtls_static_target})
122 endif()
123--
1242.20.1
125