From c6e4ab00a8e6c67864eca6752efd03c6d6b64b56 Mon Sep 17 00:00:00 2001 From: Jaeden Amero Date: Thu, 1 Nov 2018 16:56:08 +0000 Subject: [PATCH] Use parent module includes when used as a submodule For Makefiles, enable overriding where includes can come from in order to enable the parent module to set the include path. This allows the parent module to specify that its config.h should be used, even when the submodule when built standalone would use a different config.h. For CMake, always look in the parent's include folder and our own. List the parent's include folder first, so that preference is given to parent include files. --- library/CMakeLists.txt | 6 ++++++ library/Makefile | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index ba137b9f89..433fab11cd 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -146,6 +146,9 @@ if(USE_STATIC_MBEDTLS_LIBRARY) add_library(${mbedcrypto_static_target} STATIC ${src_crypto}) 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/) if(USE_CRYPTO_SUBMODULE) install(TARGETS ${mbedcrypto_static_target} @@ -170,6 +173,9 @@ if(USE_SHARED_MBEDTLS_LIBRARY) add_library(mbedcrypto SHARED ${src_crypto}) set_target_properties(mbedcrypto PROPERTIES VERSION 2.14.0 SOVERSION 3) target_link_libraries(mbedcrypto ${libs}) + target_include_directories(mbedcrypto + PUBLIC ${CMAKE_SOURCE_DIR}/include/ + PUBLIC ${CMAKE_SOURCE_DIR}/crypto/include/) if(USE_CRYPTO_SUBMODULE) install(TARGETS mbedcrypto diff --git a/library/Makefile b/library/Makefile index 83afa661e0..5814ae8a17 100644 --- a/library/Makefile +++ b/library/Makefile @@ -5,7 +5,8 @@ CFLAGS ?= -O2 WARNING_CFLAGS ?= -Wall -W -Wdeclaration-after-statement LDFLAGS ?= -LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../include -D_FILE_OFFSET_BITS=64 +CRYPTO_INCLUDES ?= -I../include +LOCAL_CFLAGS = $(WARNING_CFLAGS) $(CRYPTO_INCLUDES) -D_FILE_OFFSET_BITS=64 LOCAL_LDFLAGS = ifdef DEBUG