Skip to content

Commit 17e567b

Browse files
committed
vcpkg root
1 parent 9bf061b commit 17e567b

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

projectm-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "projectm-sys"
3-
version = "1.0.9"
3+
version = "1.0.10-rc.1"
44
edition = "2021"
55
rust-version = "1.65"
66
authors = ["AnomieVision <[email protected]>", "Mischa Spiegelmock <[email protected]>"]

projectm-sys/build.rs

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ use crate::build_bindgen::bindgen;
66

77
fn main() {
88
// Get the path to the projectM source code
9-
let projectm_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("libprojectM");
9+
let projectm_path =
10+
PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("libprojectM");
1011

1112
// Check if the libprojectM source code exists
1213
if !projectm_path.exists() {
1314
println!("cargo:warning=The libprojectM source code is missing.");
14-
println!("cargo:warning=If you are building from a git clone, please run 'git submodule update --init --recursive'.");
15+
println!(
16+
"cargo:warning=If you are building from a git clone, please run 'git submodule update --init --recursive'."
17+
);
1518
println!("cargo:warning=If you downloaded this crate from crates.io, please ensure that the crate was packaged correctly.");
1619
std::process::exit(1);
1720
}
@@ -32,19 +35,45 @@ fn main() {
3235
}
3336
};
3437

38+
let vcpkg_root = PathBuf::from(vcpkg_root);
39+
let vcpkg_toolchain = vcpkg_root
40+
.join("scripts")
41+
.join("buildsystems")
42+
.join("vcpkg.cmake");
43+
44+
if !vcpkg_toolchain.exists() {
45+
println!(
46+
"cargo:warning=The vcpkg toolchain file was not found at: {}",
47+
vcpkg_toolchain.display()
48+
);
49+
std::process::exit(1);
50+
}
51+
52+
// Set VCPKG_ROOT for CMake
53+
env::set_var("VCPKG_ROOT", &vcpkg_root);
54+
55+
// Optionally set CMAKE_PREFIX_PATH
56+
let vcpkg_installed = vcpkg_root.join("installed").join("x64-windows-static-md");
57+
3558
// Configure and build libprojectM using CMake for Windows
3659
dst = cmake::Config::new(&projectm_path)
3760
.generator("Visual Studio 17 2022")
3861
.define(
3962
"CMAKE_TOOLCHAIN_FILE",
40-
format!("{}/scripts/buildsystems/vcpkg.cmake", vcpkg_root),
63+
&vcpkg_toolchain,
4164
)
4265
.define("VCPKG_TARGET_TRIPLET", "x64-windows-static-md")
4366
.define(
4467
"CMAKE_MSVC_RUNTIME_LIBRARY",
4568
"MultiThreaded$<$<CONFIG:Debug>:Debug>DLL",
4669
)
4770
.define("ENABLE_PLAYLIST", enable_playlist)
71+
.define(
72+
"projectM_Eval_DIR",
73+
&projectm_path.join("vendor").join("projectm-eval"),
74+
)
75+
.define("CMAKE_PREFIX_PATH", &vcpkg_installed)
76+
.define("CMAKE_VERBOSE_MAKEFILE", "ON")
4877
.define("BUILD_TESTING", "OFF")
4978
.define("BUILD_EXAMPLES", "OFF")
5079
.build();

0 commit comments

Comments
 (0)