views:

6984

answers:

3

Hi,

I am working on an open source C++ project, for code that compiles on Linux and Windows. I use cmake to build the code on Linux. For ease of dev-setup and political reasons, I must stick to visual studio project files/editor on Windows (I can't switch to Code::Blocks, for example). I see instructions to generate visual studio files using cmake, as here.

Have you used cmake to generate visual studio files before? How has been your experience? Suppose I want to add a new file to my project. What is the workflow for this?

+12  A: 

cmake is actually pretty good for this, the key part was everyone on the windows side has to remember to run cmake before loading in the solution, and everyone on our mac side would have to remember to run it before make. The hardest part was as a windows developer making sure your structural changes were in the cmakelist.txt file and not in the solution or project files as those changes would probably get lost and even if not lost would not get transfered over to the mac side who also needed them, and the Mac guys would need to remember not to modify the make file for the same reasons. It just requires a little thought and patience but there will be mistakes at first. But if you are using continuous integration on both sides then these will get shook out early and people will eventually get in the habit.

Alex
+3  A: 

As Alex says, it works very well. The only tricky part is to remember to make any changes in the cmake files, rather than from within Visual Studio. So on all platforms, the workflow is similar to if you'd used plain old makefiles.

But it's fairly easy to work with, and I've had no issues with cmake generating invalid files or anything like that, so I wouldn't worry too much.

jalf
+7  A: 

We moved our department's build chain to CMake, and we had a few internal roadbumps since other departments where using our project files and where accustomed to just importing them into their solutions. We also had some complaints about CMake not being fully integrated into the Visual Studio project/solution manager, so files had to be added manually to CMakeLists.txt; this was a major break in the workflow people were used to.

But in general, it was a quite smooth transition. We're very happy since we don't have to deal with project files anymore.

The concrete workflow for adding a new file to a project is really simple:

  1. Create the file, make sure it is in the correct place.
  2. Add the file to CMakeLists.txt.
  3. Build.

CMake 2.6 automatically reruns itself if any CMakeLists.txt files have changed (and (semi-)automatically reloads the solution/projects).

Remember that if you're doing out-of-source builds, you need to be careful not to create the source file in the build directory (since Visual Studio only knows about the build directory).

JesperE