diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 90c5d16..8d7a5b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -136,17 +136,23 @@ jobs: - name: docking feature run: cargo test --workspace --all-targets --features docking - - name: freetype feature + - name: freetype feature (non-Windows, pkg-config) if: matrix.os != 'windows-latest' run: cargo test --workspace --all-targets --features freetype - - name: all features + - name: freetype and docking (non-Windows, pkg-config) if: matrix.os != 'windows-latest' - run: cargo test --workspace --all-targets --features docking,freetype + run: cargo test --workspace --all-targets --features freetype,docking - - name: doc tests - run: cargo test --workspace --doc + - name: freetype feature (Windows, vcpkg) + if: matrix.os == 'windows-latest' + run: cargo test --workspace --all-targets --features freetype,use-vcpkg + - name: freetype and docking (Windows, vcpkg) + if: matrix.os == 'windows-latest' + run: cargo test --workspace --all-targets --features freetype,docking,use-vcpkg + + - run: cargo test --workspace --doc # run to check for lint problems - name: build documentation run: cargo doc diff --git a/imgui-sys/Cargo.toml b/imgui-sys/Cargo.toml index a4205a6..c3ae64b 100644 --- a/imgui-sys/Cargo.toml +++ b/imgui-sys/Cargo.toml @@ -33,9 +33,11 @@ cfg-if = "1" [build-dependencies] cc = "1.0" pkg-config = { version="0.3", optional=true } +vcpkg = { version="0.2.15", optional=true } [features] default = [] wasm = [] -freetype = ["pkg-config"] docking = [] +freetype = ["pkg-config"] +use-vcpkg = ["vcpkg"] diff --git a/imgui-sys/build.rs b/imgui-sys/build.rs index 04ea9d1..59d372a 100644 --- a/imgui-sys/build.rs +++ b/imgui-sys/build.rs @@ -9,11 +9,29 @@ const DEFINES: &[(&str, Option<&str>)] = &[ ("IMGUI_DISABLE_OSX_FUNCTIONS", None), ]; +#[cfg(feature = "freetype")] +fn find_freetype() -> Vec> { + #[cfg(not(feature = "use-vcpkg"))] + match pkg_config::Config::new().find("freetype2") { + Ok(freetype) => freetype.include_paths, + Err(err) => panic!("cannot find freetype: {}", err), + } + #[cfg(feature = "use-vcpkg")] + match vcpkg::find_package("freetype") { + Ok(freetype) => freetype.include_paths, + Err(err) => panic!("cannot find freetype: {}", err), + } +} + +// Output define args for compiler fn main() -> std::io::Result<()> { // Root of imgui-sys let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")); - // Output define args for compiler + println!( + "cargo:THIRD_PARTY={}", + manifest_dir.join("third-party").display() + ); for (key, value) in DEFINES.iter() { println!("cargo:DEFINE_{}={}", key, value.unwrap_or("")); } @@ -53,9 +71,7 @@ fn main() -> std::io::Result<()> { // Freetype font rasterizer feature #[cfg(feature = "freetype")] { - // Find library - let freetype = pkg_config::Config::new().find("freetype2").unwrap(); - for include in freetype.include_paths.iter() { + for include in find_freetype() { build.include(include); } // Set flag for dear imgui diff --git a/imgui-sys/third-party/imgui-docking/cimgui.cpp b/imgui-sys/third-party/imgui-docking/cimgui.cpp index 3466f54..26487b7 100644 --- a/imgui-sys/third-party/imgui-docking/cimgui.cpp +++ b/imgui-sys/third-party/imgui-docking/cimgui.cpp @@ -5245,7 +5245,11 @@ CIMGUI_API bool igIsKeyPressedMap(ImGuiKey key,bool repeat) } CIMGUI_API const ImFontBuilderIO* igImFontAtlasGetBuilderForStbTruetype() { +#ifdef IMGUI_ENABLE_FREETYPE + return static_cast(0); +#else return ImFontAtlasGetBuilderForStbTruetype(); +#endif } CIMGUI_API void igImFontAtlasBuildInit(ImFontAtlas* atlas) {