@@ -6,12 +6,15 @@ use crate::build_bindgen::bindgen;
66
77fn 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