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 include(${CHIP_ROOT}/config/nrfconnect/app/check-nrfconnect-version.cmake)
24 # Load NCS/Zephyr build system
25 set(CONF_FILE ${CHIP_ROOT}/config/nrfconnect/app/sample-defaults.conf prj.conf)
26 list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/nrfconnect/chip-module)
27 find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
29 project(chip-nrfconnect-lighting-example)
31 target_compile_options(app PRIVATE -Werror)
33 target_include_directories(app PRIVATE
37 ${NRFCONNECT_COMMON}/util/include
38 ${NRFCONNECT_COMMON}/app/include)
40 target_sources(app PRIVATE
42 main/LightingManager.cpp
45 ${LIGHTING_COMMON}/gen/call-command-handler.cpp
46 ${LIGHTING_COMMON}/gen/callback-stub.cpp
47 ${NRFCONNECT_COMMON}/util/LEDWidget.cpp
48 ${NRFCONNECT_COMMON}/util/NFCWidget.cpp
49 ${NRFCONNECT_COMMON}/util/ThreadUtil.cpp
50 ${NRFCONNECT_COMMON}/app/Service.cpp
51 ${CHIP_ROOT}/src/app/server/DataModelHandler.cpp
52 ${CHIP_ROOT}/src/app/reporting/reporting-default-configuration.cpp
53 ${CHIP_ROOT}/src/app/reporting/reporting.cpp
54 ${CHIP_ROOT}/src/app/util/af-event.cpp
55 ${CHIP_ROOT}/src/app/util/af-main-common.cpp
56 ${CHIP_ROOT}/src/app/util/attribute-size.cpp
57 ${CHIP_ROOT}/src/app/util/attribute-storage.cpp
58 ${CHIP_ROOT}/src/app/util/attribute-table.cpp
59 ${CHIP_ROOT}/src/app/util/binding-table.cpp
60 ${CHIP_ROOT}/src/app/util/chip-message-send.cpp
61 ${CHIP_ROOT}/src/app/util/client-api.cpp
62 ${CHIP_ROOT}/src/app/util/ember-print.cpp
63 ${CHIP_ROOT}/src/app/util/message.cpp
64 ${CHIP_ROOT}/src/app/util/process-cluster-message.cpp
65 ${CHIP_ROOT}/src/app/util/process-global-message.cpp
66 ${CHIP_ROOT}/src/app/util/util.cpp
67 ${CHIP_ROOT}/src/app/clusters/bindings/bindings.cpp
68 ${CHIP_ROOT}/src/app/clusters/on-off-server/on-off.cpp
69 ${CHIP_ROOT}/src/app/clusters/level-control/level-control.cpp
70 ${CHIP_ROOT}/src/app/clusters/network-commissioning/network-commissioning-ember.cpp
71 ${CHIP_ROOT}/src/app/clusters/network-commissioning/network-commissioning.cpp
74 if (CONFIG_CHIP_PW_RPC)
76 set(PIGWEED_ROOT "${CHIP_ROOT}/third_party/pigweed/repo")
77 include(${PIGWEED_ROOT}/pw_build/pigweed.cmake)
78 include(${PIGWEED_ROOT}/pw_protobuf_compiler/proto.cmake)
80 pw_set_backend(pw_log pw_log_basic)
81 pw_set_backend(pw_assert pw_assert_log)
82 pw_set_backend(pw_sys_io pw_sys_io.nrfconnect)
83 set(dir_pw_third_party_nanopb PRESENT CACHE STRING ${CHIP_ROOT}/third_party/nanopb/repo FORCE)
85 add_subdirectory(third_party/connectedhomeip/examples/platform/nrfconnect/pw_sys_io)
86 add_subdirectory(third_party/connectedhomeip/third_party/nanopb/repo)
87 add_subdirectory(third_party/connectedhomeip/third_party/pigweed/repo)
89 pw_proto_library(pigweed_lighting_protolib
91 main/pigweed_lighting.proto
94 target_sources(app PRIVATE
96 ../../common/pigweed/RpcService.cpp
97 ../../common/pigweed/nrfconnect/PigweedLoggerMutex.cpp
98 ${NRFCONNECT_COMMON}/util/PigweedLogger.cpp
101 target_include_directories(app PRIVATE
102 ${ZEPHYR_BASE}/subsys // required to get access to `log_output_std.h`
103 ${PIGWEED_ROOT}/pw_sys_io/public
104 ${CHIP_ROOT}/src/lib/support
105 ${CHIP_ROOT}/src/system
107 ../../common/pigweed/nrfconnect)
109 target_link_libraries(app PRIVATE
110 pigweed_lighting_protolib.nanopb_rpc
117 endif(CONFIG_CHIP_PW_RPC)