2 # Copyright (c) 2020 Project CHIP Authors
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 cmake_minimum_required(VERSION 3.13.1)
18 get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/third_party/connectedhomeip REALPATH)
19 get_filename_component(NRFCONNECT_COMMON ${CHIP_ROOT}/examples/platform/nrfconnect REALPATH)
20 get_filename_component(LIGHTING_COMMON ${CHIP_ROOT}/examples/lighting-app/lighting-common REALPATH)
22 set(CONF_FILE ${CHIP_ROOT}/config/nrfconnect/app/sample-defaults.conf prj.conf)
24 # Load NCS/Zephyr build system
25 list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/nrfconnect/chip-module)
26 find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
28 project(chip-nrfconnect-lighting-example)
30 target_compile_options(app PRIVATE -Werror)
32 target_include_directories(app PRIVATE
36 ${NRFCONNECT_COMMON}/util/include
37 ${NRFCONNECT_COMMON}/app/include)
39 target_sources(app PRIVATE
41 main/LightingManager.cpp
44 ${LIGHTING_COMMON}/gen/call-command-handler.cpp
45 ${LIGHTING_COMMON}/gen/callback-stub.cpp
46 ${NRFCONNECT_COMMON}/util/LEDWidget.cpp
47 ${NRFCONNECT_COMMON}/util/NFCWidget.cpp
48 ${NRFCONNECT_COMMON}/util/ThreadUtil.cpp
49 ${NRFCONNECT_COMMON}/app/Service.cpp
50 ${CHIP_ROOT}/src/app/server/DataModelHandler.cpp
51 ${CHIP_ROOT}/src/app/reporting/reporting-default-configuration.cpp
52 ${CHIP_ROOT}/src/app/reporting/reporting.cpp
53 ${CHIP_ROOT}/src/app/util/af-event.cpp
54 ${CHIP_ROOT}/src/app/util/af-main-common.cpp
55 ${CHIP_ROOT}/src/app/util/attribute-size.cpp
56 ${CHIP_ROOT}/src/app/util/attribute-storage.cpp
57 ${CHIP_ROOT}/src/app/util/attribute-table.cpp
58 ${CHIP_ROOT}/src/app/util/binding-table.cpp
59 ${CHIP_ROOT}/src/app/util/chip-message-send.cpp
60 ${CHIP_ROOT}/src/app/util/client-api.cpp
61 ${CHIP_ROOT}/src/app/util/ember-print.cpp
62 ${CHIP_ROOT}/src/app/util/message.cpp
63 ${CHIP_ROOT}/src/app/util/process-cluster-message.cpp
64 ${CHIP_ROOT}/src/app/util/process-global-message.cpp
65 ${CHIP_ROOT}/src/app/util/util.cpp
66 ${CHIP_ROOT}/src/app/clusters/bindings/bindings.cpp
67 ${CHIP_ROOT}/src/app/clusters/on-off-server/on-off.cpp
68 ${CHIP_ROOT}/src/app/clusters/level-control/level-control.cpp
69 ${CHIP_ROOT}/src/app/clusters/network-commissioning/network-commissioning-ember.cpp
70 ${CHIP_ROOT}/src/app/clusters/network-commissioning/network-commissioning.cpp
73 if (CONFIG_CHIP_PW_RPC)
75 set(PIGWEED_ROOT "${CHIP_ROOT}/third_party/pigweed/repo")
76 include(${PIGWEED_ROOT}/pw_build/pigweed.cmake)
77 include(${PIGWEED_ROOT}/pw_protobuf_compiler/proto.cmake)
79 pw_set_backend(pw_log pw_log_basic)
80 pw_set_backend(pw_assert pw_assert_log)
81 pw_set_backend(pw_sys_io pw_sys_io.nrfconnect)
82 set(dir_pw_third_party_nanopb PRESENT CACHE STRING ${CHIP_ROOT}/third_party/nanopb/repo FORCE)
84 add_subdirectory(third_party/connectedhomeip/examples/platform/nrfconnect/pw_sys_io)
85 add_subdirectory(third_party/connectedhomeip/third_party/nanopb/repo)
86 add_subdirectory(third_party/connectedhomeip/third_party/pigweed/repo)
88 pw_proto_library(pigweed_lighting_protolib
90 main/pigweed_lighting.proto
93 target_sources(app PRIVATE
95 ../../common/pigweed/RpcService.cpp
96 ../../common/pigweed/nrfconnect/PigweedLoggerMutex.cpp
97 ${NRFCONNECT_COMMON}/util/PigweedLogger.cpp
100 target_include_directories(app PRIVATE
101 ${ZEPHYR_BASE}/subsys // required to get access to `log_output_std.h`
102 ${PIGWEED_ROOT}/pw_sys_io/public
103 ${CHIP_ROOT}/src/lib/support
104 ${CHIP_ROOT}/src/system
106 ../../common/pigweed/nrfconnect)
108 target_link_libraries(app PRIVATE
109 pigweed_lighting_protolib.nanopb_rpc
116 endif(CONFIG_CHIP_PW_RPC)