Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use existing Visual Studio project in cmake

I have a bunch of cmake generated projects and one which was created under MSVS. I want to have it added whenever I rerun cmake. Now I have to generate solution by cmake and then add existing project to the solution from the MSVS GUI but it is a bit tedious.

Is there a way to automatize the process?

like image 620
ixSci Avatar asked Jun 04 '13 05:06

ixSci


People also ask

How do I open an existing CMake project in Visual Studio?

On the Visual Studio main menu, choose File > Open > CMake. Navigate to the CMakeLists. txt file in the root of the bullet3 repo you just downloaded. As soon as you open the folder, your folder structure becomes visible in the Solution Explorer.

How do I CMake a project?

Run the cmake executable or the cmake-gui to configure the project and then build it with your chosen build tool. Run the install step by using the install option of the cmake command (introduced in 3.15, older versions of CMake must use make install ) from the command line, or build the INSTALL target from an IDE.


1 Answers

I found a way to do it:

It is as simple as just put the following line in a cmake file: INCLUDE_EXTERNAL_MSPROJECT(<Name> <Path>)

I've also had dependencies in my MS project and those dependencies were on the projects generated by the CMake so I had to re-add deps every time I do clean build or change the machine I'm working on. It was solved with manually setting GUID for the CMake generated projects: SET(${PROJECT_NAME}_GUID_CMAKE "<GUID>" CACHE INTERNAL "Project GUID")

So now I can work with projects generated by CMake and "native" MSVS project without any pain.

like image 170
ixSci Avatar answered Oct 14 '22 08:10

ixSci