From 67d4b555b8e31a93eb6466c77cdd81fc78d613fe Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Fri, 22 May 2020 21:59:53 +0200 Subject: [PATCH] cmake: Limit scope of 3rd party definitions Don't define anymore globally third party include directories and compile definitions. Declare them within the scope of the crypto library target as per the third party source files. Note that targets linking to the crypto library inherit from the third party public include directories. Signed-off-by: Ronald Cron --- CMakeLists.txt | 3 --- library/CMakeLists.txt | 12 ++++++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c3c86ce1..de50c72aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -219,10 +219,7 @@ endif(ENABLE_ZLIB_SUPPORT) add_subdirectory(include) add_subdirectory(3rdparty) -include_directories(${thirdparty_inc_public}) -include_directories(${thirdparty_inc}) list(APPEND libs ${thirdparty_lib}) -add_definitions(${thirdparty_def}) add_subdirectory(library) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 960e232ae..0a8b87cc7 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -163,7 +163,11 @@ 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 ${MBEDTLS_DIR}/include/) + 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}) set_target_properties(${mbedx509_static_target} PROPERTIES OUTPUT_NAME mbedx509) @@ -188,7 +192,11 @@ if(USE_SHARED_MBEDTLS_LIBRARY) set_target_properties(mbedcrypto PROPERTIES VERSION 2.22.0 SOVERSION 4) target_link_libraries(mbedcrypto ${libs}) target_include_directories(mbedcrypto - PUBLIC ${MBEDTLS_DIR}/include/) + PUBLIC ${MBEDTLS_DIR}/include/ + PUBLIC ${thirdparty_inc_public} + PRIVATE ${thirdparty_inc}) + target_compile_definitions(mbedcrypto + PRIVATE ${thirdparty_def}) add_library(mbedx509 SHARED ${src_x509}) set_target_properties(mbedx509 PROPERTIES VERSION 2.22.0 SOVERSION 1)