-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for VCPKG on Windows #493
base: master
Are you sure you want to change the base?
Conversation
@aljen Thanks for the PR! I'm not a windows (nor vcpkg) guy, so not sure how to review this. I'll reach out to the community in discord and see if anyone volunteers. |
No problem! :) |
panic!("GDAL_VCPKG requires GDAL_VCPKG_TRIPLET to be set."); | ||
} | ||
|
||
let vcpkg_root = vcpkg_root.unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let vcpkg_root = vcpkg_root.unwrap(); | |
let vcpkg_root = vcpkg_root.expect("GDAL_VCPKG requires VCPKG_ROOT to be set"); |
(same for vcpkg_triplet
)
let pkg_config = env::var("PKG_CONFIG"); | ||
let pkg_config_path = env::var("PKG_CONFIG_PATH"); | ||
|
||
let required_pkg_config = vcpkg_install_dir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand these. If we know the correct PKG_CONFIG
, why does the user have to set it?
.unwrap() | ||
.to_owned(); | ||
|
||
let valid_pkg_config = match pkg_config { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would look a bit nicer like:
if !matches!(pkg_config, Some(required_pkg_config)) {
panic!("GDAL_VCPKG requires PKG_CONFIG to be set to '{required_pkg_config}'.");
}
println!("cargo:rustc-link-search={}", lib_dir.to_str().unwrap()); | ||
println!("cargo:rustc-link-lib={link_type}={lib_name}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -2,6 +2,10 @@ | |||
|
|||
## Unreleased | |||
|
|||
- Added support for VCPKG. Set `GDAL_VCPKG` environment variable to `1` to enable VCPKG support. Set `GDAL_VCPKG_TRIPLET` to the desired triplet (e.g. `x64-windows-static`). `VCPKG_ROOT` must point to the VCPKG root directory. Install GDAL with `vcpkg install gdal:x64-windows-static` (or the desired triplet). Install pkgconf with `vcpkg install pkgconf:x64-windows-static`, set `PKG_CONFIG` to the pkgconf executable (e.g. `%VCPKG_ROOT%\installed\x64-windows-static\tools\pkgconf\pkgconf.exe`) and `PKG_CONFIG_PATH` to `%VCPKG_ROOT%\installed\x64-windows-static\lib\pkgconfig`. When building non-static version, copy missing dlls from `%VCPKG_ROOT%\installed\x64-windows\bin` to the executable directory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move the usage instructions into the gdal-sys
README.md
. That way, people might actually find them 🙂.
Ping @aljen can you take another look at this? |
Yeah, I planned to do this over the weekend, I had my plate full lately :) |
CHANGES.md
if knowledge of this change could be valuable to users.GDAL_VCPKG
environment variable to1
to enable VCPKG support.GDAL_VCPKG_TRIPLET
to the desired triplet (e.g.x64-windows-static
).VCPKG_ROOT
must point to the VCPKG root directory.vcpkg install gdal:x64-windows-static
(or the desired triplet).vcpkg install pkgconf:x64-windows-static
.PKG_CONFIG
to the pkgconf executable (e.g.%VCPKG_ROOT%\installed\x64-windows-static\tools\pkgconf\pkgconf.exe
).PKG_CONFIG_PATH
to%VCPKG_ROOT%\installed\x64-windows-static\lib\pkgconfig
.%VCPKG_ROOT%\installed\x64-windows\bin
to the executable directory.