mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-29 18:54:20 +01:00
Factor common library properties
All libraries (should) rely on the same directory structure. Instead of repeating the same clauses 6 times (3 libraries times 2 build modes), set the include paths, compile definitions and install instructions with a single piece of code. Include the 3rdparty directory for all libraries, not just crypto. It's currently only needed for crypto, but that's just happenstance. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
db09ef6d22
commit
3ca8a9285e
@ -148,10 +148,15 @@ if (NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY)
|
|||||||
message(FATAL_ERROR "Need to choose static or shared mbedtls build!")
|
message(FATAL_ERROR "Need to choose static or shared mbedtls build!")
|
||||||
endif(NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY)
|
endif(NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY)
|
||||||
|
|
||||||
|
set(target_libraries "mbedcrypto" "mbedx509" "mbedtls")
|
||||||
|
|
||||||
if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY)
|
if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY)
|
||||||
set(mbedtls_static_target "mbedtls_static")
|
set(mbedtls_static_target "mbedtls_static")
|
||||||
set(mbedx509_static_target "mbedx509_static")
|
set(mbedx509_static_target "mbedx509_static")
|
||||||
set(mbedcrypto_static_target "mbedcrypto_static")
|
set(mbedcrypto_static_target "mbedcrypto_static")
|
||||||
|
set(target_libraries "mbedcrypto" "mbedx509" "mbedtls")
|
||||||
|
list(APPEND target_libraries
|
||||||
|
"mbedcrypto_static" "mbedx509_static" "mbedtls_static")
|
||||||
elseif(USE_STATIC_MBEDTLS_LIBRARY)
|
elseif(USE_STATIC_MBEDTLS_LIBRARY)
|
||||||
set(mbedtls_static_target "mbedtls")
|
set(mbedtls_static_target "mbedtls")
|
||||||
set(mbedx509_static_target "mbedx509")
|
set(mbedx509_static_target "mbedx509")
|
||||||
@ -162,58 +167,41 @@ if(USE_STATIC_MBEDTLS_LIBRARY)
|
|||||||
add_library(${mbedcrypto_static_target} STATIC ${src_crypto})
|
add_library(${mbedcrypto_static_target} STATIC ${src_crypto})
|
||||||
set_target_properties(${mbedcrypto_static_target} PROPERTIES OUTPUT_NAME mbedcrypto)
|
set_target_properties(${mbedcrypto_static_target} PROPERTIES OUTPUT_NAME mbedcrypto)
|
||||||
target_link_libraries(${mbedcrypto_static_target} ${libs})
|
target_link_libraries(${mbedcrypto_static_target} ${libs})
|
||||||
target_include_directories(${mbedcrypto_static_target}
|
|
||||||
PUBLIC ${MBEDTLS_DIR}/include/
|
|
||||||
PUBLIC ${thirdparty_inc_public}
|
|
||||||
PRIVATE ${thirdparty_inc})
|
|
||||||
target_compile_definitions(${mbedcrypto_static_target}
|
|
||||||
PRIVATE ${thirdparty_def})
|
|
||||||
|
|
||||||
add_library(${mbedx509_static_target} STATIC ${src_x509})
|
add_library(${mbedx509_static_target} STATIC ${src_x509})
|
||||||
set_target_properties(${mbedx509_static_target} PROPERTIES OUTPUT_NAME mbedx509)
|
set_target_properties(${mbedx509_static_target} PROPERTIES OUTPUT_NAME mbedx509)
|
||||||
target_link_libraries(${mbedx509_static_target} ${libs} ${mbedcrypto_static_target})
|
target_link_libraries(${mbedx509_static_target} ${libs} ${mbedcrypto_static_target})
|
||||||
target_include_directories(${mbedx509_static_target}
|
|
||||||
PUBLIC ${MBEDTLS_DIR}/include/)
|
|
||||||
|
|
||||||
add_library(${mbedtls_static_target} STATIC ${src_tls})
|
add_library(${mbedtls_static_target} STATIC ${src_tls})
|
||||||
set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls)
|
set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls)
|
||||||
target_link_libraries(${mbedtls_static_target} ${libs} ${mbedx509_static_target})
|
target_link_libraries(${mbedtls_static_target} ${libs} ${mbedx509_static_target})
|
||||||
target_include_directories(${mbedtls_static_target}
|
|
||||||
PUBLIC ${MBEDTLS_DIR}/include/)
|
|
||||||
|
|
||||||
install(TARGETS ${mbedtls_static_target} ${mbedx509_static_target} ${mbedcrypto_static_target}
|
|
||||||
DESTINATION ${LIB_INSTALL_DIR}
|
|
||||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
|
||||||
endif(USE_STATIC_MBEDTLS_LIBRARY)
|
endif(USE_STATIC_MBEDTLS_LIBRARY)
|
||||||
|
|
||||||
if(USE_SHARED_MBEDTLS_LIBRARY)
|
if(USE_SHARED_MBEDTLS_LIBRARY)
|
||||||
|
|
||||||
add_library(mbedcrypto SHARED ${src_crypto})
|
add_library(mbedcrypto SHARED ${src_crypto})
|
||||||
set_target_properties(mbedcrypto PROPERTIES VERSION 2.22.0 SOVERSION 4)
|
set_target_properties(mbedcrypto PROPERTIES VERSION 2.22.0 SOVERSION 4)
|
||||||
target_link_libraries(mbedcrypto ${libs})
|
target_link_libraries(mbedcrypto ${libs})
|
||||||
target_include_directories(mbedcrypto
|
|
||||||
PUBLIC ${MBEDTLS_DIR}/include/
|
|
||||||
PUBLIC ${thirdparty_inc_public}
|
|
||||||
PRIVATE ${thirdparty_inc})
|
|
||||||
target_compile_definitions(mbedcrypto
|
|
||||||
PRIVATE ${thirdparty_def})
|
|
||||||
|
|
||||||
add_library(mbedx509 SHARED ${src_x509})
|
add_library(mbedx509 SHARED ${src_x509})
|
||||||
set_target_properties(mbedx509 PROPERTIES VERSION 2.22.0 SOVERSION 1)
|
set_target_properties(mbedx509 PROPERTIES VERSION 2.22.0 SOVERSION 1)
|
||||||
target_link_libraries(mbedx509 ${libs} mbedcrypto)
|
target_link_libraries(mbedx509 ${libs} mbedcrypto)
|
||||||
target_include_directories(mbedx509
|
|
||||||
PUBLIC ${MBEDTLS_DIR}/include/)
|
|
||||||
|
|
||||||
add_library(mbedtls SHARED ${src_tls})
|
add_library(mbedtls SHARED ${src_tls})
|
||||||
set_target_properties(mbedtls PROPERTIES VERSION 2.22.0 SOVERSION 13)
|
set_target_properties(mbedtls PROPERTIES VERSION 2.22.0 SOVERSION 13)
|
||||||
target_link_libraries(mbedtls ${libs} mbedx509)
|
target_link_libraries(mbedtls ${libs} mbedx509)
|
||||||
target_include_directories(mbedtls
|
endif(USE_SHARED_MBEDTLS_LIBRARY)
|
||||||
PUBLIC ${MBEDTLS_DIR}/include/)
|
|
||||||
|
|
||||||
install(TARGETS mbedtls mbedx509 mbedcrypto
|
foreach(target IN LISTS target_libraries)
|
||||||
|
target_include_directories(${target}
|
||||||
|
PUBLIC ${MBEDTLS_DIR}/include/
|
||||||
|
PUBLIC ${thirdparty_inc_public}
|
||||||
|
PRIVATE ${thirdparty_inc})
|
||||||
|
target_compile_definitions(${target}
|
||||||
|
PRIVATE ${thirdparty_def})
|
||||||
|
install(TARGETS ${target}
|
||||||
DESTINATION ${LIB_INSTALL_DIR}
|
DESTINATION ${LIB_INSTALL_DIR}
|
||||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||||
endif(USE_SHARED_MBEDTLS_LIBRARY)
|
endforeach(target)
|
||||||
|
|
||||||
add_custom_target(lib DEPENDS mbedcrypto mbedx509 mbedtls)
|
add_custom_target(lib DEPENDS mbedcrypto mbedx509 mbedtls)
|
||||||
if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY)
|
if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY)
|
||||||
|
Loading…
Reference in New Issue
Block a user