-
Notifications
You must be signed in to change notification settings - Fork 1
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
Package visual studio compiler for use with tool_requires #1
Comments
This is an interesting question. Using VS packaged in a Conan package could be very useful for many users, even ourselves. So far it has been the licensing that didn't allow to do it, but it would be great to know how this can be possible. For the CMake integration, I am not sure why the |
Of course! I have also come across the conf_info parameter "tools.microsoft.msbuild:installation_path", and been trying to work with that, but still no success. Toolcahin recipe:
One strange thing I have discovered is how paths are constructed. If I print Regards |
Interesting. I heard from some users that it is actually possible to use just the toolchain somehow, without needing the full VS installation, making the package way smaller and faster to install.
Probably |
Sorry this was not followed up, we didn't have time enough to prioritize it. |
I have succeeded with: from conan import ConanFile
from conan.tools.files import copy, save
import os
class x86_64_windows_msvc2017Conan(ConanFile):
name = "msvc"
version = "16"
settings = "os", "arch"
def package(self):
# toolchain
version_vs = "16.11.34601.136" # This must be tuned, might be automatically obtained too
toolchain = f'set(CMAKE_GENERATOR_INSTANCE "$ENV{{CONAN_MSVC_16_FOLDER}},version={version_vs}" CACHE INTERNAL "")'
save(self, os.path.join(self.package_folder, "msvc_toolchain.cmake"), toolchain)
# packaging
vs_path = "C:/Program Files (x86)/Microsoft Visual Studio/2019_2/Community"
copy(self, "*", src=vs_path, dst=self.package_folder)
def package_info(self):
f = os.path.join(self.package_folder, "msvc_toolchain.cmake")
self.conf_info.append("tools.cmake.cmaketoolchain:user_toolchain", f)
pf = self.package_folder.replace("\\", "/")
self.buildenv_info.define("CONAN_MSVC_16_FOLDER", pf) And just apply it with a profile to other cmake recipe:
The keys:
I have packaged the whole directory, I am pretty sure it is possible to discard many of those parts and make the package smaller. Does this help? We might want to document this, write a short blog post or something too. |
I am submitting conan-io/docs#3666 to the docs, it will close this ticket as resolved, thanks! |
Colleagues from the team have reported:
I guess this is more complicated that it seems on the surface. Not sure it is worth the effort, and this is not part of Conan client anyway, but more like a recipe/community thing. Any feedback so far @klausholstjacobsen ? Thanks! |
No further feedback here, and this is not a Conan client issue, but more like very specific about how VS could be made relocatable, and this would be outside of our scope, as much as we would like to help, we don't have enough resources to keep investigating this. I think this is definitely possible, as I have heard from some users that they managed to do it, so I am not closing this, and instead moving it to the "contrib" repo, where in the future this would make sense to be contributed. |
What is your question?
OS: windows 10
conan 1.56
I have packaged the "Visual Studio 2017" toolchain in a package and use it on the consumer side in my build profile [tool_requires].
My consumer I would then like my consumer recipe to detect and use the toolchain provided by conan like this:
[path to toolchain] points to "...2017\BuildTools" within the package as indicated by cmake.
But CMakeToolchain refuses to detect anything but the installed Visual Studio in "c:\Program Files....."
Is there a way for me to be able to force the "system" to use the visual studio compiler from my package so that other developers in my team can build without manually installing visual studio.
Regards
Klaus
Have you read the CONTRIBUTING guide?
The text was updated successfully, but these errors were encountered: