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.
diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
index ba137b9..433fab1 100644
--- a/library/CMakeLists.txt
+++ b/library/CMakeLists.txt
@@ -146,6 +146,9 @@
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 @@
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