Skip to content

Commit 5094c50

Browse files
committed
cmake: use project name instead of hardcoded name
This commit offers to give an arbitrary name to the Rust application project under CMake. Indeed, before this commit, the CMake project for the Rust application had the name `librustapp`. Now, it can be set with any value.
1 parent eda3a85 commit 5094c50

File tree

9 files changed

+10
-9
lines changed

9 files changed

+10
-9
lines changed

CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ function(rust_cargo_application)
8686
endif()
8787
set(BUILD_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${RUST_TARGET}/${RUST_BUILD_TYPE}")
8888

89+
set(RUST_LIBRARY_NAME "${CMAKE_PROJECT_NAME}")
8990
set(CARGO_TARGET_DIR "${CMAKE_CURRENT_BINARY_DIR}/rust/target")
90-
set(RUST_LIBRARY "${CARGO_TARGET_DIR}/${RUST_TARGET}/${RUST_BUILD_TYPE}/librustapp.a")
91+
set(RUST_LIBRARY "${CARGO_TARGET_DIR}/${RUST_TARGET}/${RUST_BUILD_TYPE}/lib${RUST_LIBRARY_NAME}.a")
9192
set(SAMPLE_CARGO_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/rust/sample-cargo-config.toml")
9293

9394
# The generated C binding wrappers. These are bindgen-generated wrappers for the inline functions

samples/hello_world/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ cmake_minimum_required(VERSION 3.20.0)
44

55
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
66

7-
project(hello_rust_world)
7+
project(hello_world)
88
rust_cargo_application()

samples/hello_world/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
[package]
55
# This must be rustapp for now.
6-
name = "rustapp"
6+
name = "hello_world"
77
version = "3.7.0"
88
edition = "2021"
99
description = "A sample hello world application in Rust"

samples/hello_world/sample.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
sample:
22
description: Hello world, but in Rust
3-
name: hello rust world
3+
name: hello world
44
common:
55
harness: console
66
harness_config:

samples/philosophers/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
[package]
55
# This must be rustapp for now.
6-
name = "rustapp"
6+
name = "philosophers"
77
version = "3.7.0"
88
edition = "2021"
99
description = "A sample hello world application in Rust"

tests/time/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
cmake_minimum_required(VERSION 3.20.0)
44

55
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
6-
project(time_rust)
6+
project(time)
77

88
target_sources(app PRIVATE src/times.c)
99

tests/time/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
[package]
55
# This must be rustapp for now.
6-
name = "rustapp"
6+
name = "time"
77
version = "3.7.0"
88
edition = "2021"
99
description = "Tests of time"

tests/timer/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
cmake_minimum_required(VERSION 3.20.0)
44

55
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
6-
project(timer_rust)
6+
project(timer)
77

88
rust_cargo_application()

tests/timer/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
[package]
55
# This must be rustapp for now.
6-
name = "rustapp"
6+
name = "timer"
77
version = "3.7.0"
88
edition = "2021"
99
description = "Tests of timeers"

0 commit comments

Comments
 (0)