Skip to content

Commit 073ff62

Browse files
adigienordicjm
authored andcommitted
samples: matter: Add Data Model target
Move Data Model sources to separate target. Signed-off-by: Adrian Gielniewski <[email protected]>
1 parent ce698d8 commit 073ff62

File tree

11 files changed

+80
-62
lines changed

11 files changed

+80
-62
lines changed

applications/matter_bridge/CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
1010

1111
project(matter-bridge)
1212

13-
# Enable GNU STD support and initialize the Matter Data Model.
13+
# Enable GNU STD support.
1414
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/config/nrfconnect/app/enable-gnu-std.cmake)
15-
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/src/app/chip_data_model.cmake)
1615

1716
# NORDIC SDK APP START
1817

1918
# Include all source files that are located in the Matter common directory.
2019
include(${ZEPHYR_NRF_MODULE_DIR}/samples/matter/common/cmake/source_common.cmake)
2120

21+
# Include Data Model utils
22+
include(${ZEPHYR_NRF_MODULE_DIR}/samples/matter/common/cmake/data_model.cmake)
23+
2224
target_include_directories(app PRIVATE
2325
src
2426
src/bridged_device_types
@@ -127,10 +129,7 @@ endif() # CONFIG_BRIDGE_HUMIDITY_SENSOR_BRIDGED_DEVICE
127129

128130
endif() # CONFIG_BRIDGED_DEVICE_BT
129131

130-
chip_configure_data_model(app
131-
INCLUDE_SERVER
132-
BYPASS_IDL
133-
GEN_DIR ${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/zap-generated
132+
ncs_configure_data_model(
134133
ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/bridge.zap
135134
)
136135
# NORDIC SDK APP END

applications/matter_weather_station/CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
1010

1111
project(matter-weather-station)
1212

13-
# Enable GNU STD support and initialize the Matter Data Model.
13+
# Enable GNU STD support.
1414
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/config/nrfconnect/app/enable-gnu-std.cmake)
15-
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/src/app/chip_data_model.cmake)
1615

1716
# NORDIC SDK APP START
1817

1918
# Include all source files that are located in the Matter common directory.
2019
include(${ZEPHYR_NRF_MODULE_DIR}/samples/matter/common/cmake/source_common.cmake)
2120

21+
# Include Data Model utils
22+
include(${ZEPHYR_NRF_MODULE_DIR}/samples/matter/common/cmake/data_model.cmake)
23+
2224
target_include_directories(app PRIVATE
2325
src
2426
${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}
@@ -31,10 +33,7 @@ target_sources(app PRIVATE
3133
src/buzzer.cpp
3234
)
3335

34-
chip_configure_data_model(app
35-
INCLUDE_SERVER
36-
BYPASS_IDL
37-
GEN_DIR ${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/zap-generated
36+
ncs_configure_data_model(
3837
ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/weather-station.zap
3938
)
4039
# NORDIC SDK APP END
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/src/app/chip_data_model.cmake)
8+
9+
function(ncs_configure_data_model)
10+
cmake_parse_arguments(ARG "" "ZAP_FILE" "EXTERNAL_CLUSTERS" ${ARGN})
11+
12+
if(NOT ARG_ZAP_FILE)
13+
message(FATAL_ERROR "ZAP_FILE argument is required")
14+
endif()
15+
16+
target_include_directories(matter-data-model
17+
PUBLIC
18+
${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}
19+
)
20+
21+
chip_configure_data_model(matter-data-model
22+
BYPASS_IDL
23+
GEN_DIR ${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/zap-generated
24+
ZAP_FILE ${ARG_ZAP_FILE}
25+
EXTERNAL_CLUSTERS ${ARG_EXTERNAL_CLUSTERS}
26+
)
27+
endfunction()

samples/matter/light_bulb/CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
1010

1111
project(matter-light-bulb)
1212

13-
# Enable GNU STD support and initialize the Matter Data Model.
13+
# Enable GNU STD support.
1414
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/config/nrfconnect/app/enable-gnu-std.cmake)
15-
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/src/app/chip_data_model.cmake)
1615

1716
# NORDIC SDK APP START
1817

1918
# Include all source files that are located in the Matter common directory.
2019
include(${ZEPHYR_NRF_MODULE_DIR}/samples/matter/common/cmake/source_common.cmake)
2120

21+
# Include Data Model utils
22+
include(${ZEPHYR_NRF_MODULE_DIR}/samples/matter/common/cmake/data_model.cmake)
23+
2224
target_include_directories(app PRIVATE
2325
src
2426
${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}
@@ -34,10 +36,7 @@ target_sources(app PRIVATE
3436
src/zcl_callbacks.cpp
3537
)
3638

37-
chip_configure_data_model(app
38-
INCLUDE_SERVER
39-
BYPASS_IDL
40-
GEN_DIR ${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/zap-generated
39+
ncs_configure_data_model(
4140
ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/light_bulb.zap
4241
)
4342
# NORDIC SDK APP END

samples/matter/light_switch/CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
1010

1111
project(matter-light-switch)
1212

13-
# Enable GNU STD support and initialize the Matter Data Model.
13+
# Enable GNU STD support.
1414
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/config/nrfconnect/app/enable-gnu-std.cmake)
15-
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/src/app/chip_data_model.cmake)
1615

1716
# NORDIC SDK APP START
1817

1918
# Include all source files that are located in the Matter common directory.
2019
include(${ZEPHYR_NRF_MODULE_DIR}/samples/matter/common/cmake/source_common.cmake)
2120

21+
# Include Data Model utils
22+
include(${ZEPHYR_NRF_MODULE_DIR}/samples/matter/common/cmake/data_model.cmake)
23+
2224
target_include_directories(app PRIVATE
2325
src
2426
${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}
@@ -35,10 +37,7 @@ target_sources(app PRIVATE
3537
${ZEPHYR_NRF_MODULE_DIR}/samples/matter/common/src/binding/binding_handler.cpp
3638
)
3739

38-
chip_configure_data_model(app
39-
INCLUDE_SERVER
40-
BYPASS_IDL
41-
GEN_DIR ${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/zap-generated
40+
ncs_configure_data_model(
4241
ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/light_switch.zap
4342
)
4443
# NORDIC SDK APP END

samples/matter/lock/CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@ cmake_minimum_required(VERSION 3.20.0)
99
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
1010
project(matter-lock)
1111

12-
# Enable GNU STD support and initialize the Matter Data Model.
12+
# Enable GNU STD support.
1313
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/config/nrfconnect/app/enable-gnu-std.cmake)
14-
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/src/app/chip_data_model.cmake)
1514

1615
# NORDIC SDK APP START
1716

1817
# Include all source files that are located in the Matter common directory.
1918
include(${ZEPHYR_NRF_MODULE_DIR}/samples/matter/common/cmake/source_common.cmake)
2019

20+
# Include Data Model utils
21+
include(${ZEPHYR_NRF_MODULE_DIR}/samples/matter/common/cmake/data_model.cmake)
22+
2123
target_include_directories(app PRIVATE
2224
src
2325
${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}
@@ -48,15 +50,13 @@ if(CONFIG_THREAD_WIFI_SWITCHING)
4850
)
4951
endif()
5052

51-
# Do not treat warnings as errors while the variable may be uninitialized for this sample.
53+
# Do not treat warnings as errors while the variable may be uninitialized for this sample data model.
5254
# In the door-lock-server implementation, there is a warning that the C++ "optional"
5355
# variable may be uninitialized, but actually, it is wrongly interpreted by the Zephyr toolchain.
54-
target_compile_options(app PRIVATE -Wno-error=maybe-uninitialized)
56+
target_compile_options(matter-data-model PRIVATE -Wno-error=maybe-uninitialized)
5557

56-
chip_configure_data_model(app
57-
INCLUDE_SERVER
58-
BYPASS_IDL
59-
GEN_DIR ${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/zap-generated
58+
ncs_configure_data_model(
6059
ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/lock.zap
6160
)
61+
6262
# NORDIC SDK APP END

samples/matter/manufacturer_specific/CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ project(matter-manufacturer_specific)
1313
# Override zap-generated directory.
1414
get_filename_component(CHIP_APP_ZAP_DIR ${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/zap-generated REALPATH CACHE)
1515

16-
# Enable GNU STD support and initialize the Matter Data Model.
16+
# Enable GNU STD support.
1717
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/config/nrfconnect/app/enable-gnu-std.cmake)
18-
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/src/app/chip_data_model.cmake)
1918

2019
# NORDIC SDK APP START
2120

2221
# Include all source files that are located in the Matter common directory.
2322
include(${ZEPHYR_NRF_MODULE_DIR}/samples/matter/common/cmake/source_common.cmake)
2423

24+
# Include Data Model utils
25+
include(${ZEPHYR_NRF_MODULE_DIR}/samples/matter/common/cmake/data_model.cmake)
26+
2527
target_include_directories(app PRIVATE
2628
src
2729
${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}
@@ -33,10 +35,7 @@ target_sources(app PRIVATE
3335
src/main.cpp
3436
)
3537

36-
chip_configure_data_model(app
37-
INCLUDE_SERVER
38-
BYPASS_IDL
39-
GEN_DIR ${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/zap-generated
38+
ncs_configure_data_model(
4039
ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/manufacturer_specific.zap
4140
EXTERNAL_CLUSTERS "NORDIC_DEV_KIT_CLUSTER"
4241
)

samples/matter/smoke_co_alarm/CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
1010

1111
project(matter-smoke-co-alarm)
1212

13-
# Enable GNU STD support and initialize the Matter Data Model.
13+
# Enable GNU STD support.
1414
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/config/nrfconnect/app/enable-gnu-std.cmake)
15-
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/src/app/chip_data_model.cmake)
1615

1716
# NORDIC SDK APP START
1817

1918
# Include all source files that are located in the Matter common directory.
2019
include(${ZEPHYR_NRF_MODULE_DIR}/samples/matter/common/cmake/source_common.cmake)
2120

21+
# Include Data Model utils
22+
include(${ZEPHYR_NRF_MODULE_DIR}/samples/matter/common/cmake/data_model.cmake)
23+
2224
target_include_directories(app PRIVATE
2325
src
2426
${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}
@@ -30,10 +32,7 @@ target_sources(app PRIVATE
3032
src/zcl_callbacks.cpp
3133
)
3234

33-
chip_configure_data_model(app
34-
INCLUDE_SERVER
35-
BYPASS_IDL
36-
GEN_DIR ${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/zap-generated
35+
ncs_configure_data_model(
3736
ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/smoke_co_alarm.zap
3837
)
3938
# NORDIC SDK APP END

samples/matter/template/CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
1010

1111
project(matter-template)
1212

13-
# Enable GNU STD support and initialize the Matter Data Model.
13+
# Enable GNU STD support.
1414
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/config/nrfconnect/app/enable-gnu-std.cmake)
15-
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/src/app/chip_data_model.cmake)
1615

1716
# NORDIC SDK APP START
1817

1918
# Include all source files that are located in the Matter common directory.
2019
include(${ZEPHYR_NRF_MODULE_DIR}/samples/matter/common/cmake/source_common.cmake)
2120

21+
# Include Data Model utils
22+
include(${ZEPHYR_NRF_MODULE_DIR}/samples/matter/common/cmake/data_model.cmake)
23+
2224
target_include_directories(app PRIVATE
2325
src
2426
${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}
@@ -29,10 +31,7 @@ target_sources(app PRIVATE
2931
src/main.cpp
3032
)
3133

32-
chip_configure_data_model(app
33-
INCLUDE_SERVER
34-
BYPASS_IDL
35-
GEN_DIR ${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/zap-generated
34+
ncs_configure_data_model(
3635
ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/template.zap
3736
)
3837
# NORDIC SDK APP END

samples/matter/thermostat/CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
1010

1111
project(matter-template)
1212

13-
# Enable GNU STD support and initialize the Matter Data Model.
13+
# Enable GNU STD support.
1414
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/config/nrfconnect/app/enable-gnu-std.cmake)
15-
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/src/app/chip_data_model.cmake)
1615

1716
# NORDIC SDK APP START
1817

1918
# Include all source files that are located in the Matter common directory.
2019
include(${ZEPHYR_NRF_MODULE_DIR}/samples/matter/common/cmake/source_common.cmake)
2120

21+
# Include Data Model utils
22+
include(${ZEPHYR_NRF_MODULE_DIR}/samples/matter/common/cmake/data_model.cmake)
23+
2224
target_include_directories(app PRIVATE
2325
src
2426
${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}
@@ -34,10 +36,7 @@ target_sources(app PRIVATE
3436
${ZEPHYR_NRF_MODULE_DIR}/samples/matter/common/src/binding/binding_handler.cpp
3537
)
3638

37-
chip_configure_data_model(app
38-
INCLUDE_SERVER
39-
BYPASS_IDL
40-
GEN_DIR ${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/zap-generated
39+
ncs_configure_data_model(
4140
ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH}/thermostat.zap
4241
)
4342
# NORDIC SDK APP END

0 commit comments

Comments
 (0)