mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-28 00:21:48 +03:00
Remove use of CMAKE_SOURCE_DIR
Remove use of CMAKE_SOURCE_DIR in case mbedtls is built from within another CMake project. Define MBEDTLS_DIR to ${CMAKE_CURRENT_SOURCE_DIR} in the main CMakeLists.txt file and refer to that when defining target include paths to enable mbedtls to be built as a sub project. Fixes https://github.com/ARMmbed/mbedtls/issues/2609 Signed-off-by: Ashley Duncan <ashes.man@gmail.com> Signed-off-by: Jaeden Amero <jaeden.amero@arm.com>
This commit is contained in:
committed by
Jaeden Amero
parent
54b8eabd76
commit
d85a7e9b09
@ -2,6 +2,13 @@ option(USE_STATIC_MBEDTLS_LIBRARY "Build mbed TLS static library." ON)
|
||||
option(USE_SHARED_MBEDTLS_LIBRARY "Build mbed TLS shared library." OFF)
|
||||
option(LINK_WITH_PTHREAD "Explicitly link mbed TLS library to pthread." OFF)
|
||||
|
||||
# Set the project root directory if it's not already defined, as may happen if
|
||||
# the library folder is included directly by a parent project, without
|
||||
# including the top level CMakeLists.txt.
|
||||
if(NOT DEFINED MBEDTLS_DIR)
|
||||
set(MBEDTLS_DIR ${CMAKE_SOURCE_DIR})
|
||||
endif()
|
||||
|
||||
set(src_crypto
|
||||
aes.c
|
||||
aesni.c
|
||||
@ -72,9 +79,9 @@ set(src_crypto
|
||||
if(USE_CRYPTO_SUBMODULE)
|
||||
set(src_crypto
|
||||
${src_crypto}
|
||||
${CMAKE_SOURCE_DIR}/library/version.c
|
||||
${CMAKE_SOURCE_DIR}/library/version_features.c
|
||||
${CMAKE_SOURCE_DIR}/library/error.c
|
||||
${MBEDTLS_DIR}/library/version.c
|
||||
${MBEDTLS_DIR}/library/version_features.c
|
||||
${MBEDTLS_DIR}/library/error.c
|
||||
)
|
||||
else()
|
||||
set(src_crypto
|
||||
@ -133,8 +140,8 @@ if(USE_STATIC_MBEDTLS_LIBRARY)
|
||||
set_target_properties(${mbedcrypto_static_target} PROPERTIES OUTPUT_NAME mbedcrypto)
|
||||
target_link_libraries(${mbedcrypto_static_target} ${libs})
|
||||
target_include_directories(${mbedcrypto_static_target}
|
||||
PUBLIC ${CMAKE_SOURCE_DIR}/include/
|
||||
PUBLIC ${CMAKE_SOURCE_DIR}/crypto/include/)
|
||||
PUBLIC ${MBEDTLS_DIR}/include/
|
||||
PUBLIC ${MBEDTLS_DIR}/crypto/include/)
|
||||
|
||||
install(TARGETS ${mbedcrypto_static_target}
|
||||
DESTINATION ${LIB_INSTALL_DIR}
|
||||
@ -146,8 +153,8 @@ if(USE_SHARED_MBEDTLS_LIBRARY)
|
||||
set_target_properties(mbedcrypto PROPERTIES VERSION 2.17.0 SOVERSION 3)
|
||||
target_link_libraries(mbedcrypto ${libs})
|
||||
target_include_directories(mbedcrypto
|
||||
PUBLIC ${CMAKE_SOURCE_DIR}/include/
|
||||
PUBLIC ${CMAKE_SOURCE_DIR}/crypto/include/)
|
||||
PUBLIC ${MBEDTLS_DIR}/include/
|
||||
PUBLIC ${MBEDTLS_DIR}/crypto/include/)
|
||||
|
||||
install(TARGETS mbedcrypto
|
||||
DESTINATION ${LIB_INSTALL_DIR}
|
||||
|
Reference in New Issue
Block a user