Reputation: 11181
I have a large project that is split in two parts:
Part 1 needs to be cross platform, we use CMake to setup all the projects file for that.
Part 2 is for windows only. It is configured in a .SLN file, and it depends on Part 1.
We generate a Part1.sln using cmake, but at this point we have two different solutions (Part1.sln and Part2.sln), and it is annoying to constantly switch from one to the other.
Apparently using CMake for Part 2 is not an option because most of our developers can not edit cmake files and would like to modify the solutions directly from MSVC.
As far as I know it is not possible to "include" a visual studio solution inside another one, but I might be wrong on that.
We would like to generate a single .SLN file that contains both part 1 and part 2, possibly using CMake itself or some other method.
Upvotes: 6
Views: 3133
Reputation: 11181
We ended up using include_external_msproject
. The final solution consist of a main cmake file that mixes standard cmake files (add_subdirectory
), and vcproj files. The only (minor) downside was that the inter-project dependencies in Part2.sln had to be re-implemented inside the top level CMakeLists.txt
.
Upvotes: 5
Reputation: 54589
You are right in that you cannot include a full Visual Studio solution file in another one.
However, the majority of the information from the Part 1 project that you are interested in is probably not in the solution itself, but in the individual .vcxproj
project files. And those can be included by as many solutions as you want.
Since you say that using CMake on the Part 2 project is out of the question, you will not get a perfect solution here. Someone needs to do a CMake run on Part 1 to generate the project files. This could be done by a custom build step in a Part 2 project though. The Part 2 solution file would then contain hardcoded references to the projects generated by that CMake run.
If you change the project structure in Part 1, you will have to adjust the Part 2 solution accordingly. This gets particularly nasty if the inter-project dependencies for two projects from Part 1 change. Also, if you forget to run CMake on Part 1 before loading the solution, you will end up with a bunch of load failed
projects, but that's not a big deal. Just run CMake and do a Right Click->Reload Project on the respective projects.
Upvotes: 2