-
Notifications
You must be signed in to change notification settings - Fork 125
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
MSVC: Use bundled CMake if present and no other is in path #145
base: master
Are you sure you want to change the base?
Conversation
028787e
to
ae7f5ec
Compare
Is there documentation to link to of how this is found? Otherwise all I can really do is rubber-stamp this as I don't really have any idea if this is correct and there's not really a great way to test this on CI |
I don't think there's any official documentation mentioning CMake installation location. It just happen to be for last few MSVC versions. For example flutter tool which invokes during build locates it same way. |
This may need some work. If there are multiple VS versions installed side by side (i.e. 2019 and 2022) this finds CMake from 2019, but will fail because it tries to use it with 2022 generator. |
Ok, sorry but I've decided that I will no longer maintain this crate and it needs a new maintainer. |
Another issue with the proposed implementation (and which I had in my first try) is that you cannot rely on devenv.exe being present (e.g. if only Build Tools are installed). It seems the correct way is to use the related COM interface to get the base directory and then append Note you can also use In any case, the |
Can the CMAKE_COMMAND env-var be used ? it seems to be a standard (albeit hard to find) way? https://cmake.org/cmake/help/latest/variable/CMAKE_COMMAND.html I would maybe also look into https://cmake.org/cmake/help/latest/variable/CMAKE_VS_DEVENV_COMMAND.html I have a similar, perhaps, case whgen a newb run into a wall: DDoSolitary/yasfw#49 However i do not have giant VS IDE amd instead try to wrap my mind around VC++ Build Tools and VSCode I also just had installed VCPKG. Now i seem to have two CMAKE instances:
Looks kind of redundant and weird, but that is how Microsoft is making it yet. A faux path would be to rely on the standard Windows sequence of finding an application by document file extension. To me |
fwiw here's how i've solved it (works for VS or BuildTools-only installs) https://github.com/unicorn-engine/unicorn/blob/2912cd1e299456e71f9fc52b046d84cf1aff2144/bindings/rust/build.rs#L21 |
This seems to be related to #142 Just cross-linking two discussion pages, making it easier to find |
Mind rebasing to fix conflicts? This path seems right to me (matches the path on my windows machine, and the path that other projects seem to have used for some time without problems). |
I do think cc-rs should have a proper way to get the base directory but an interim solution does make sense. |
MSVC already comes with CMake installed (by default if desktop development with c++ was specified), but CMake-rs doesn't know about it.
This PR will use the bundled installation, but only if there is no other CMake installation in path.