Reputation: 34175
I decided to convert my Visual Studio project to CMake to develop on multiple platforms. But I wonder how to effectively apply versioning to a CMake project.
Say, from the CMake project I generated a Visual Studio project on Windows, and set up a make file on Linux. I don't want to include those platform specific files in commits. Is it best practice to exclude all those files using .gitignore
?
This is what first came to my mind, and I would like to know if this is how its done right. For example, I could also include projects for all different platforms in my repository.
Upvotes: 0
Views: 69
Reputation: 76519
Yes, if you use CMake as a base project file, by all means do not add the generated files to the repository. They're effectively useless as a shared thing and often very computer-specific.
As said in the comments (by @Peter, which I shamelessly copy here for better visibility), it is often a good idea to build outside your source tree (unlike the default behavior of Visual Studio). Basically, you do (from the source directory)
cd ..
mkdir project-build && cd project-build
cmake ../project
You can tell CMake to use a specific "generator" with the -G
commandline option. Check its help output for details. You can also do this through CMake's GUI.
Upvotes: 4