From eb33978fa83009508a0c231a5ea7c3387c0edb2b Mon Sep 17 00:00:00 2001 From: Ashley Duncan Date: Mon, 29 Apr 2019 20:35:06 +1200 Subject: [PATCH] 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 #2609 Signed-off-by: Ashley Duncan Signed-off-by: Jaeden Amero --- CMakeLists.txt | 2 ++ library/CMakeLists.txt | 16 ++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 38c800608..7bbfb201a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,8 @@ else() project("mbed TLS" C) endif() +set(MBEDTLS_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + option(USE_PKCS11_HELPER_LIBRARY "Build mbed TLS with the pkcs11-helper library." OFF) option(ENABLE_ZLIB_SUPPORT "Build mbed TLS with zlib library." OFF) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index ea069ab86..c82784ee1 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -151,15 +151,15 @@ if(USE_STATIC_MBEDTLS_LIBRARY) set_target_properties(${mbedx509_static_target} PROPERTIES OUTPUT_NAME mbedx509) target_link_libraries(${mbedx509_static_target} ${libs} ${mbedcrypto_static_target}) target_include_directories(${mbedx509_static_target} - PUBLIC ${CMAKE_SOURCE_DIR}/include/ - PUBLIC ${CMAKE_SOURCE_DIR}/crypto/include/) + PUBLIC ${MBEDTLS_DIR}/include/ + PUBLIC ${MBEDTLS_DIR}/crypto/include/) add_library(${mbedtls_static_target} STATIC ${src_tls}) set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls) target_link_libraries(${mbedtls_static_target} ${libs} ${mbedx509_static_target}) target_include_directories(${mbedtls_static_target} - PUBLIC ${CMAKE_SOURCE_DIR}/include/ - PUBLIC ${CMAKE_SOURCE_DIR}/crypto/include/ + PUBLIC ${MBEDTLS_DIR}/include/ + PUBLIC ${MBEDTLS_DIR}/crypto/include/ ) @@ -175,15 +175,15 @@ if(USE_SHARED_MBEDTLS_LIBRARY) set_target_properties(mbedx509 PROPERTIES VERSION 2.18.0 SOVERSION 1) target_link_libraries(mbedx509 ${libs} mbedcrypto) target_include_directories(mbedx509 - PUBLIC ${CMAKE_SOURCE_DIR}/include/ - PUBLIC ${CMAKE_SOURCE_DIR}/crypto/include/) + PUBLIC ${MBEDTLS_DIR}/include/ + PUBLIC ${MBEDTLS_DIR}/crypto/include/) add_library(mbedtls SHARED ${src_tls}) set_target_properties(mbedtls PROPERTIES VERSION 2.18.0 SOVERSION 13) target_link_libraries(mbedtls ${libs} mbedx509) target_include_directories(mbedtls - PUBLIC ${CMAKE_SOURCE_DIR}/include/ - PUBLIC ${CMAKE_SOURCE_DIR}/crypto/include/) + PUBLIC ${MBEDTLS_DIR}/include/ + PUBLIC ${MBEDTLS_DIR}/crypto/include/) install(TARGETS mbedtls mbedx509 DESTINATION ${LIB_INSTALL_DIR}