diff --git a/config/common/cmake/chip_gn.cmake b/config/common/cmake/chip_gn.cmake index bfaa91ab28200b..618fbfccec3632 100644 --- a/config/common/cmake/chip_gn.cmake +++ b/config/common/cmake/chip_gn.cmake @@ -18,7 +18,7 @@ # @file # CMake file defining to setup and build the Matter library # and other optional libraries like unit tests. -# Matter headers and libraries are exposed to the application +# Matter headers and libraries are exposed to the application # as a specific interface target. # Since Matter doesn't provide native CMake support, ExternalProject # module is used to build the required artifacts with GN meta-build @@ -57,7 +57,7 @@ endif() # Macros # ============================================================================== # Setup and build the Matter library and other optional libraries like unit tests. -# Expose Matter headers & libraries to the application as specific +# Expose Matter headers & libraries to the application as specific # interface target. # [Args]: # target - interface target name @@ -65,19 +65,21 @@ endif() # LIB_SHELL Build and add Matter shell library # LIB_PW_RPC Build and add Matter PW RPC library # LIB_TESTS Build and add Matter unit tests library +# LIB_MBEDTLS Build and add Matter mbedtls library # DEVICE_INFO_EXAMPLE_PROVIDER Add example device info provider support # # GN_DEPENDENCIES List of targets that should be built before Matter GN project macro(matter_build target) set(options) set(oneValueArgs - LIB_TESTS - LIB_SHELL + LIB_TESTS + LIB_SHELL LIB_PW_RPC + LIB_MBEDTLS DEVICE_INFO_EXAMPLE_PROVIDER ) set(multiValueArgs GN_DEPENDENCIES) - + cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) set(MATTER_LIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/lib) @@ -85,6 +87,10 @@ macro(matter_build target) # Prepare Matter libraries that the application should be linked with set(MATTER_LIBRARIES -lCHIP) + if (ARG_LIB_MBEDTLS) + list(APPEND MATTER_LIBRARIES -lmbedtls) + endif() + if (ARG_LIB_SHELL) list(APPEND MATTER_LIBRARIES -lCHIPShell) endif() @@ -115,7 +121,7 @@ macro(matter_build target) BUILD_COMMAND ${CMAKE_COMMAND} -E echo "Starting Matter library build in ${CMAKE_CURRENT_BINARY_DIR}" COMMAND ${Python3_EXECUTABLE} ${CHIP_ROOT}/config/common/cmake/make_gn_args.py @args.tmp > args.gn.tmp # Replace the config only if it has changed to avoid triggering unnecessary rebuilds - COMMAND bash -c "(! diff -q args.gn.tmp args.gn && mv args.gn.tmp args.gn) || true" + COMMAND bash -c "(! diff -q args.gn.tmp args.gn && mv args.gn.tmp args.gn) || true" # Regenerate the ninja build system COMMAND ${GN_EXECUTABLE} --root=${CHIP_ROOT} @@ -127,7 +133,7 @@ macro(matter_build target) COMMAND ${CMAKE_COMMAND} -E echo "Matter library build complete" INSTALL_COMMAND "" # Byproducts are removed by the clean target removing config and .ninja_deps - # allows a rebuild of the external project after the clean target has been run. + # allows a rebuild of the external project after the clean target has been run. BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/args.gn ${CMAKE_CURRENT_BINARY_DIR}/build.ninja ${CMAKE_CURRENT_BINARY_DIR}/.ninja_deps @@ -156,6 +162,12 @@ macro(matter_build target) ${CMAKE_CURRENT_BINARY_DIR}/gen/include ) + if (ARG_LIB_MBEDTLS) + target_include_directories(${target} INTERFACE + ${CHIP_ROOT}/third_party/mbedtls/repo/include + ) + endif() + # ============================================================================== # Link required libraries # ============================================================================== diff --git a/config/common/cmake/chip_gn_args.cmake b/config/common/cmake/chip_gn_args.cmake index 98a9bcc35c7c07..663e7f49977030 100644 --- a/config/common/cmake/chip_gn_args.cmake +++ b/config/common/cmake/chip_gn_args.cmake @@ -16,7 +16,7 @@ # # @file -# CMake file that allows collecting C/C++ compiler flags passed to +# CMake file that allows collecting C/C++ compiler flags passed to # the Matter build system. # @@ -165,11 +165,11 @@ endmacro() macro(matter_common_gn_args) set(options) set(oneValueArgs - DEBUG - LIB_TESTS - LIB_SHELL + DEBUG + LIB_TESTS + LIB_SHELL LIB_PW_RPC - DEVICE_INFO_EXAMPLE_PROVIDER + DEVICE_INFO_EXAMPLE_PROVIDER PROJECT_CONFIG ) @@ -196,7 +196,7 @@ macro(matter_common_gn_args) matter_add_gn_arg_bool ("is_debug" ${ARG_DEBUG}) matter_add_gn_arg_bool ("chip_build_tests" ${ARG_LIB_TESTS}) matter_add_gn_arg_bool ("chip_build_libshell" ${ARG_LIB_SHELL}) - + if (ARG_LIB_PW_RPC) matter_add_gn_arg_bool ("chip_build_pw_rpc_lib" ${ARG_LIB_PW_RPC}) endif() # ARG_LIB_PW_RPC