Sharpmake
Sharpmake copied to clipboard
Visual Studio Linux target improvement
- Visual Studio 2022 allows targeting a Linux platform as output.
- Windows 10 allows to install a Linux distribution and run software in it, using WSL (Windows Subsystem for Linux).
- Together, they allow to very conveniently test Linux build, directly from VS, using the platform Toolset ()
I saw that Sharpmake also allows us to target Linux in it Visual Studio projects, unfortunately, with only one 'Platform Toolset' (GCC for Remote Linux).
Would it be possible to add the new Linux Toolset to the project configuration? The WSL toolset would need to not have the '$(RemoteProjectDir)' added to the Output/Intermediate Directories.

Indeed, we could expose more options to allow this :)
Note that we mostly use cross-compilation with FastBuild and clang from windows when targeting linux, I hope to one day find time to write a sample in this repo to show how to do that :)
The depot https://github.com/sammyfreg/hello-world also generate a Linux solution using Sharpmake. I have been using this repo to test setuping my build system for a new project.
It seems like its not missing much to be able to specify a toolset targetting WSL. And using WSL seems much easier than setuping a remote Linux config.
I just noticed that we can already specify the Linux toolset on Sharpmake 0.21, using
conf.Options.Add(Linux.Options.General.VcPlatformToolset.WSL2_1_0);
I was still on 0.18, and that option wasn't available at the time. Now I only need to figure out some compiling error linked to path settings.
I have been unable to generate a working VS Linux project. It almost works but fails on the obj path.
Its giving me an error with a path badly joined with a 'home' directory and missing a '/'.
/mnt//~/projects/ExampleLibobj/linux_debugdefault
/mnt//+~?ExampleLibobj->ExampleLib/obj
I have looked at the project file itself, and couldn't find any reference to the /mnt or ~ in its settings.
When comparing with a working minimal VS Linux project (created using 'new project' in VS) I have been unable to find any significant difference that would cause this path error.
- New Project sets
ToolsVersion="Current"while Sharpmake setsToolsVersion="17.0" - New Project sets
<PropertyGroup Label="Globals"><Keyword>Linux</Keyword> ...while Sharpmake does not
The one difference I could not explain for looking at the project file, was that the properties dialog was missing a few elements in the Sharpmake version :

Versus New Project version :

However, adding the same properties values in the project file directly doesn't seem to fix the issue either. At this point, I believe I will set having a working VS Linux output, aside. If someone is interested in figuring this out, https://github.com/sammyfreg/hello-world contains all of the needed files (the sample is very simple, with only the bare minimum sources files)
I just ran into this and its not fun. But I have managed to track the out of the box not working down to two problems, at least for me.
- <RemoteRootDir> is set to "", a newly created project in visual studio sets this to ~/projects, I do believe this becoming an option on the configuration would be great.
- RemoteProjectDir gets resolved using TargetPath
Changing this for both Library and None library output types to ProjectPath seems to do the trick.
~I will try to put up a PR for this.~
Edit: After testing this on a bigger project, a lot of different path problems showed up, it would require more than a single night, hopefully in the near future.