| # Copyright 2022 The Pigweed Authors |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| # use this file except in compliance with the License. You may obtain a copy of |
| # the License at |
| # |
| # https://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| # License for the specific language governing permissions and limitations under |
| # the License. |
| |
| cmake_minimum_required(VERSION 3.20) |
| |
| set(BOARD native_posix) |
| set(NO_BUILD_TYPE_WARNING ON) |
| set(CMAKE_VERBOSE_MAKEFILE ON) |
| set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
| |
| # Use this copy of Pigweed |
| get_filename_component(PW_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../pigweed" ABSOLUTE) |
| set(ENV{PW_ROOT} ${PW_ROOT}) |
| |
| set(pw_third_party_nanopb_ADD_SUBDIRECTORY ON CACHE BOOL "" FORCE) |
| |
| list(APPEND ZEPHYR_EXTRA_MODULES ${PW_ROOT}) |
| |
| find_package(Zephyr REQUIRED PATHS $ENV{ZEPHYR_BASE}) |
| project(tokenizer_demo) |
| |
| target_sources(app PRIVATE src/main.cc) |
| |
| # Add custom logic to generate database.bin |
| # The application expects it to be in the binary dir. |
| add_custom_target(database_binary |
| DEPENDS |
| ${CMAKE_BINARY_DIR}/database.bin |
| ) |
| add_custom_command( |
| OUTPUT ${CMAKE_BINARY_DIR}/database.bin |
| COMMAND |
| ${PYTHON_EXECUTABLE} |
| ${PW_ROOT}/pw_tokenizer/py/pw_tokenizer/database.py |
| create |
| --type binary |
| -d ${CMAKE_BINARY_DIR}/database.bin |
| ${CMAKE_BINARY_DIR}/zephyr/zephyr_pre0.elf |
| DEPENDS zephyr_pre0 |
| ) |
| add_dependencies(${logical_target_for_zephyr_elf} database_binary) |