cmakerustrust-cargovisual-studio-2017-build-tools

Rust on Windows CMake issue


I've installed Rust with rustup-init.exe on my PC (Windows 10 Pro) and then Microsoft Visual C++ Build Tools 2017 with Visual C++ tools for CMake option.

For simple example there is no problems:

fn main() {
   println!("Hello world!");
}

I execute cargo run command and as a result I get Hello world! as expected.


But now I want to check out Azul GUI framework

main.rs

extern crate azul;

fn main() {
   println!("Hello world!");
}

Cargo.toml

[package]
name = "my_first_azul_app"
version = "0.1.0"
authors = ["Author"]
edition = "2018"

[dependencies]
azul = { git = "https://github.com/maps4print/azul" }

When I execute cargo run command an error occurs:

...

error: failed to run custom build command for `harfbuzz-sys v0.3.0 (https://github.com/maps4print/azul-dependencies?rev=c1548977fb62399f39aa642d2e7e24a24a25246e#c1548977)`
process didn't exit successfully: `C:\Users\admin\Documents\Rust\Projects\my_first_azul_app\target\debug\build\harfbuzz-sys-37196527d1c78dd0\build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=HARFBUZZ_SYS_NO_PKG_CONFIG
running: "cmake" "C:\\Users\\admin\\.cargo\\git\\checkouts\\azul-dependencies-70bb1f94316762f9\\c154897\\harfbuzz-sys-0.3.0\\harfbuzz" "-G" "Visual Studio 15 2017 Win64" "-Thost=x64" "-DCMAKE_INSTALL_PREFIX=C:\\Users\\admin\\Documents\\Rust\\Projects\\my_first_azul_app\\target\\debug\\build\\harfbuzz-sys-9193f770b45e8642\\out" "-DCMAKE_C_FLAGS= /nologo /MD" "-DCMAKE_C_FLAGS_DEBUG= /nologo /MD" "-DCMAKE_CXX_FLAGS= /nologo /MD" "-DCMAKE_CXX_FLAGS_DEBUG= /nologo /MD" "-DCMAKE_BUILD_TYPE=Debug"

--- stderr
thread 'main' panicked at '
failed to execute command: cannot find the file specified. (os error 2)
is `cmake` not installed?

...

How to fix this issue with CMake and Rust? Should I specify CMake path or so?


Solution

  • I solved it by adding CMake bin into the PATH variables. Just searched for cmake.exe file or CMake folder in recently installed Visual Studio Build Tools directory and found cmake.exe

    For me it was C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin

    So that I didn't have to install CMake separately.

    Also I added Windows 10 SDK checkbox during installation process of Visual Studio Build Tools.

    Now there is no errors while building my project.