-
Notifications
You must be signed in to change notification settings - Fork 173
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
Clang error when VS not installed #161
Comments
Heya! When you say just skip a Visual Studio version, what behavior do you think makes the most sense? Not generate the files at all? Or generate faulty ones? We could also add a bool to control the behavior when a required value is missing. Just a side note, for your use case, you could set |
I was thinking of not generating the solution at all, if the Visual Studio install directory is not found. But this is a behaviour change beyond this clang error, so maybe at the very least, not generate the clang build target. My usercase is that I have 1 batfile generating 1 solution file per VS version (17, 19, 22). Each with MSBuild and Clang build targets (except 17). Users of my library (NetImgui) can then generates the solutions and open the one matching the version that they have installed. Maybe it could be a new solution/project option, to ignore a DevEnv output, if it is not found on the PC. As for manually specifying the clang install dir, I cannot do that, since I do not know/control the setup of people using my library. Thank you. |
So far sharpmake was allowed to generate projects and solutions even if the requirements to open them were not fulfilled, so I'm leaning towards doing that, maybe adding a warning though that we're using a fallback value for the clang version. I'll leave the issue open until it is fixed (no ETA though...). Also, you can very well chose to short-circuit one or more DevEnv from your SharpmakeMain, by adding calls to the utility methods IsVisualStudioInstalled and then adding a global fragment mask depending on the values returned. Something like: [Sharpmake.Main]
public static void SharpmakeMain(Sharpmake.Arguments arguments)
{
DevEnv foundDevEnv = 0;
foreach (var devEnv in new [] { DevEnv.vs2017, DevEnv.vs2019, DevEnv.vs2022 })
{
if (Util.IsVisualStudioInstalled(devEnv))
foundDevEnv |= devEnv;
}
if (foundDevEnv == 0)
throw new Error("Couldn't find any installed visual studio version!");
arguments.AddFragmentMask(foundDevEnv);
... // here the rest of your main
} This will force sharpmake to only generate for the installed visual studio versions. (note that I wrote that in the github comment so apologies if it doesn't compile because of typos!). |
That code snippet is doing exactly what I would like, thank you, I will try it tomorrow. I haven't tested to see what happen when requesting a Clang target, without it installed by the VS setup, it'll try it and see. |
The method I ended creating this method and calling it when adding my Targets in Project/Solution constructors. Works like a charm, though not a fan of the hardcoded 'clang.exe' file check. // Generates a solution for each Visual Studio version found
// Note: Add a Clang target when detected isntalled for that Visual Studio version
static public NetImguiTarget[] CreateTargets()
{
List<NetImguiTarget> targets = new List<NetImguiTarget>();
foreach (var devEnv in new [] { DevEnv.vs2017, DevEnv.vs2019, DevEnv.vs2022 })
{
if( Util.DirectoryExists(devEnv.GetVisualStudioDir()) ){
Compiler compiler = Compiler.MSBuild;
if(Util.FileExists(ClangForWindows.Settings.LLVMInstallDirVsEmbedded(devEnv) + @"\bin\clang.exe" )){
compiler |= Compiler.Clang;
}
targets.Add(new NetImguiTarget{DevEnv = devEnv, Compiler = compiler});
}
}
return targets.ToArray();
} |
Arf sorry about that. Glad you found a way though :) |
I just updated to the latest release of Sharpmake (0.18.1) , and noticed a solution generation error tied to the Clang toolset.
I have VS2019 installed and can successfully generate MSBuild and Clang build configs.
I then added the VS2022 config to my DevEnv, before actually installing VisualStudio 2022. This was done as a test, but I would like the generation to not fail and just skip a Visual Studio version, when it cannot be found, since I do not expect users to have all versions installed.
Thank you.
Here's the output log
The text was updated successfully, but these errors were encountered: