How to add additional directories to RSYNC used in Visual Studio 2019 Remote Linux Development using CMAKE

I have a folder structure as shown below. When I refer to project I mean in the CMAKE sense.

Root folder:
--Project A Root:
----CMakelists.txt
----CMakeSettings.json
----Target (executable) Root:
------src
--Project B Root:
----CMakelists.txt
----CMakeSettings.json
----Target (Executable) Root:
------src
--Common Libraries:
----Target C (shared Library) Root:
------CMakelists.txt
------src
----Target D (static Library) Root:
------CMakelists.txt
------src

Project A needs both Target C and Target D to build and run. Project B is the same with the executable being different.

If I open Project A’s root using open folder of Visual Studio and connect to a remote Linux machine, RSYNC syncs up the Project A’s root which includes the source. It does not sync up target C and D. So when I go to generate for Project A, CMAKE complains that it cannot find target C and D’s folders.

Question: Is there a way to add Target C and D’s folders to the RSYNC setup in the CMakeSettings.json of Project A? I want RSYNC/Visual studio to keep the necessary source for a project synced (regardless of its location) with its Linux version from Windows.

The folder structure cannot change. I cannot create a root folder that encompasses both Project A and the Common Projects library and open that because I want Project A and B to be separate.

I also have tried adding to the RSYNC command arguments in CMakeSettings.json and that did not work.

Thanks!

I suspect this is more of a VS question (there may be those here that know, but this seems more fundamentally a VS feature that isn’t covering your use case), but I would suggest making a superbuild that either uses git to reference the projects or SOURCE_DIR and something like submodules.

The way I do it using VS2022 is

    • workspace
        • project A
        • project B
        • common libraries

Crucially there is no CMakeLists.txt in the root workspace. So when you open workspace with VS2022 it asks where your root CMakeLists.txt file is, so you can choose A or B.

When it does the Linux build it copies workspace across, not just the folder that holds your root CMakeLists.txt

But it only will allow CMakeLists.txt to be in direct subfolders of workspace, not subfolders of subfolders.

Yeah, I think VS would do well with a way to say “yes, top-level is here, but please copy to the remote from N parents up”.

As a workaround, can you add a dummy CMakeLists.txt that just does an add_subdirectory to the intended project?

That would do it.

It will issue a warning about the lack of a project command. The main disadvantage is that it appears to put the build directories at the top level, but I may be wrong about that. I haven’t investigate much further as I have something that works for me,even if a bit restrictive