occt_sys/
lib.rs

1use std::{
2    env::var,
3    path::{Path, PathBuf},
4};
5
6const LIB_DIR: &str = "lib";
7const INCLUDE_DIR: &str = "include";
8
9/// Get the path to the OCCT library installation directory to be
10/// used in build scripts.
11///
12/// Only valid during build (`cargo clean` removes these files).
13pub fn occt_path() -> PathBuf {
14    // moves the output into target/TARGET/OCCT
15    // this way its less likely to be rebuilt without a cargo clean
16    Path::new(&var("OUT_DIR").expect("missing OUT_DIR")).join("../../../../OCCT")
17}
18
19/// Build the OCCT library.
20pub fn build_occt() {
21    cmake::Config::new(Path::new(env!("OCCT_SRC_DIR")))
22        .define("BUILD_PATCH", Path::new(env!("OCCT_PATCH_DIR")))
23        .define("BUILD_LIBRARY_TYPE", "Static")
24        .define("BUILD_MODULE_ApplicationFramework", "FALSE")
25        .define("BUILD_MODULE_Draw", "FALSE")
26        .define("USE_D3D", "FALSE")
27        .define("USE_DRACO", "FALSE")
28        .define("USE_EIGEN", "FALSE")
29        .define("USE_FFMPEG", "FALSE")
30        .define("USE_FREEIMAGE", "FALSE")
31        .define("USE_FREETYPE", "FALSE")
32        .define("USE_GLES2", "FALSE")
33        .define("USE_OPENGL", "FALSE")
34        .define("USE_OPENVR", "FALSE")
35        .define("USE_RAPIDJSON", "FALSE")
36        .define("USE_TBB", "FALSE")
37        .define("USE_TCL", "FALSE")
38        .define("USE_TK", "FALSE")
39        .define("USE_VTK", "FALSE")
40        .define("USE_XLIB", "FALSE")
41        .define("INSTALL_DIR_LIB", LIB_DIR)
42        .define("INSTALL_DIR_INCLUDE", INCLUDE_DIR)
43        .profile("Release")
44        .out_dir(occt_path())
45        .build();
46}