Cross platform in the IDE.

I know cmake can generate makefiles for linux and vcproj and a sln for windows.

Is there a way to create a project that opens and builds for windows in Visual Studio that also lets you use wsl:ubuntu to genrate makefile in the wsl container and let me debug in the windows IDE?

I believe this is what you are looking for:

TLRD: Visual Studio has CMake support that facilitates what you want.

Not what I was asking.
Cmake contains generators. I want the generator to create the project and sln as they are NEVER checked in.

CMAKE ----->sln, vcproj, makefile, etc

The difference here is that the config will contain a bit of both at the same time so the debug can be started in wsl and remotely debugged in IDE.

I’m not sure about remote debugging, but in terms of generating an sln, makefile, or XCode project, etc, this is CMake’s normal operation and main design goal.

Please read carefully the request. I have been using cmake since 2.x days

I am absolutly not an expert, but I have a general understanding.

What I guess I was asking, befor looking into writing it myself, was if the current generator is wsl aware and can write the bits to make such a project.

Yes. If you read the article linked above, the Visual Studio project generator can integrate with WSL.

Sorry I think that is the ssh connection to remotes host purchased from (crap cannot remmeber the name) it is a wsl1 methodolgy and not the CMake commands that generate a project that alows the integration they use now that has direct access to file system of wsl2 and no longer needs the ssh and all the file copying.
I belive that is "Visual Studio generating project from it’s template anyway and not what I was thinking.

I think I may have a way.
It would need to generate the windows into build 1 then generate the makefile into build2 the write the launch.json to or little glue file that lets Visual studio tell wsl were to build and debug

I will sleep on it. I think I can call cmake twice in a wrapping script running one in windows and one in wsl

That sounds like a valid solution.

It’s still unclear to me exactly what you’re trying to do, though.

You might be interested in


Both solutions are seriously crippled. I figured after 10+ years, they would have made some progress.

The Open Folder Experience (CMake) is centered around a single target and no way to add to the rsync. The idea to create a top level cmake then add a bunch of excludes to the rsync worked to get the files to the target. But, to be honest it was really unuseable and very unstable. Downloading the pre-beta for 2022 was more stable but intellesense cannot handle #Defines from the target OS and files in child targets. Debugging hangs on attach breakpoints etc. Pulled hair out.

The MSBuild is better in some requards but severely limited also having trouble if you are a project in a repo with additional (repo shared) files. No wild cards, no folders. 1 at a time additional files.

VisualGDB that this was based on is far far superior. And I am going to try that when I have time because it is easy to create a 3 node system, dev-build-deploy/debug

I tried CLion on the target machine and it worked great, Handled the child processes, the sudo, I just checked out the repo and gave up on the rsync. But it was short lived. 1 or 2 minutes at most. Cannot compile code with CLion with 3.6Ghz quad core and 8GB of ram. 100% swapping, no ram, unresponsive. :frowning: (never send java to do a c++ job)

What I did for now that works well is use cmake to generate unix makefiles - codelite. build from command line with make and start the process with sudo and let it spawn the child process.

Then (logged in as root via xrdp), I open the Project.workspace file and attach to the child process of interest. I can step thru code and inspect variables and set breakpoints, it has limited tab completion and goto implementation, but no “intellisense” like features, it is not that connected but it is stable.

This gets me all the power of cmake on both platforms. A full sln on VS so properties are verifiable and a full makefile hierarchy on linux.