|
| 1 | +# ############################################################################## |
| 2 | +# apps/examples/hello_rust_cargo/CMakeLists.txt |
| 3 | +# |
| 4 | +# Licensed to the Apache Software Foundation (ASF) under one or more contributor |
| 5 | +# license agreements. See the NOTICE file distributed with this work for |
| 6 | +# additional information regarding copyright ownership. The ASF licenses this |
| 7 | +# file to you under the Apache License, Version 2.0 (the "License"); you may not |
| 8 | +# use this file except in compliance with the License. You may obtain a copy of |
| 9 | +# the License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, software |
| 14 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 15 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 16 | +# License for the specific language governing permissions and limitations under |
| 17 | +# the License. |
| 18 | +# |
| 19 | +# ############################################################################## |
| 20 | + |
| 21 | +# Call cargo build from CMakeLists and add it to the build system. |
| 22 | +# Notice we should call cargo build with add_custom_target, otherwise |
| 23 | +# cargo will be called every time when cmake is configured. |
| 24 | + |
| 25 | +add_custom_target(cargo-build ALL |
| 26 | + COMMAND cargo build --release |
| 27 | + -Zbuild-std=core |
| 28 | + --manifest-path ${CMAKE_CURRENT_SOURCE_DIR}/hello/Cargo.toml |
| 29 | + --target riscv32imac-unknown-nuttx-elf |
| 30 | +) |
| 31 | + |
| 32 | +# Let target apps depends on cargo-build, so that cargo will be called before |
| 33 | +# building the target. |
| 34 | +add_dependencies(apps cargo-build) |
| 35 | + |
| 36 | +# Add static library apps/examples/hello_rust_cargo/hello/target/riscv32imac-unknown-nuttx-elf/release/libhello.a |
| 37 | +# to the build system. |
| 38 | +nuttx_library_import(hello ${CMAKE_CURRENT_SOURCE_DIR}/hello/target/riscv32imac-unknown-nuttx-elf/release/libhello.a) |
| 39 | +nuttx_add_extra_library(hello) |
| 40 | + |
| 41 | +if(CONFIG_EXAMPLES_HELLO_RUST_CARGO) |
| 42 | + nuttx_add_application( |
| 43 | + NAME |
| 44 | + ${CONFIG_EXAMPLES_HELLO_RUST_CARGO_PROGNAME} |
| 45 | + SRCS |
| 46 | + proxy_main.c |
| 47 | + STACKSIZE |
| 48 | + ${CONFIG_EXAMPLES_HELLO_STACKSIZE} |
| 49 | + PRIORITY |
| 50 | + ${CONFIG_EXAMPLES_HELLO_PRIORITY}) |
| 51 | +endif() |
0 commit comments