Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / examples / lighting-app / nrfconnect / CMakeLists.txt
1 #
2 #    Copyright (c) 2020 Project CHIP Authors
3 #
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
7 #
8 #        http://www.apache.org/licenses/LICENSE-2.0
9 #
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.
15 #
16 cmake_minimum_required(VERSION 3.13.1)
17
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)
21
22 include(${CHIP_ROOT}/config/nrfconnect/app/check-nrfconnect-version.cmake)
23
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})
28
29 project(chip-nrfconnect-lighting-example)
30
31 target_compile_options(app PRIVATE -Werror)
32
33 target_include_directories(app PRIVATE
34                            main/include
35                            ${CHIP_ROOT}/src/app
36                            ${LIGHTING_COMMON}
37                            ${NRFCONNECT_COMMON}/util/include
38                            ${NRFCONNECT_COMMON}/app/include)
39
40 target_sources(app PRIVATE
41                main/AppTask.cpp
42                main/LightingManager.cpp
43                main/main.cpp
44                main/ZclCallbacks.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/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
71                )
72
73 if (CONFIG_CHIP_NFC_COMMISSIONING)
74 target_sources(app PRIVATE
75                ${NRFCONNECT_COMMON}/util/NFCWidget.cpp
76 )
77 endif(CONFIG_CHIP_NFC_COMMISSIONING)
78
79 if (CONFIG_CHIP_PW_RPC)
80
81 set(PIGWEED_ROOT "${CHIP_ROOT}/third_party/pigweed/repo")
82 include(${PIGWEED_ROOT}/pw_build/pigweed.cmake)
83 include(${PIGWEED_ROOT}/pw_protobuf_compiler/proto.cmake)
84
85 pw_set_backend(pw_log pw_log_basic)
86 pw_set_backend(pw_assert pw_assert_log)
87 pw_set_backend(pw_sys_io pw_sys_io.nrfconnect)
88 set(dir_pw_third_party_nanopb PRESENT CACHE STRING ${CHIP_ROOT}/third_party/nanopb/repo FORCE)
89
90 add_subdirectory(third_party/connectedhomeip/examples/platform/nrfconnect/pw_sys_io)
91 add_subdirectory(third_party/connectedhomeip/third_party/nanopb/repo)
92 add_subdirectory(third_party/connectedhomeip/third_party/pigweed/repo)
93
94 pw_proto_library(pigweed_lighting_protolib
95   SOURCES
96     main/pigweed_lighting.proto
97 )
98
99 target_sources(app PRIVATE
100   main/Rpc.cpp
101   ../../common/pigweed/RpcService.cpp
102   ../../common/pigweed/nrfconnect/PigweedLoggerMutex.cpp
103   ${NRFCONNECT_COMMON}/util/PigweedLogger.cpp
104 )
105
106 target_include_directories(app PRIVATE
107   ${ZEPHYR_BASE}/subsys // required to get access to `log_output_std.h`
108   ${PIGWEED_ROOT}/pw_sys_io/public
109   ${CHIP_ROOT}/src/lib/support
110   ${CHIP_ROOT}/src/system
111   ../../common
112   ../../common/pigweed/nrfconnect)
113
114 target_link_libraries(app PRIVATE
115   pigweed_lighting_protolib.nanopb_rpc
116   pw_checksum
117   pw_hdlc
118   pw_log
119   pw_rpc.server
120 )
121
122 endif(CONFIG_CHIP_PW_RPC)