I have been taking a look at CMake for a while and I really like the idea of having code without cluttering projectfiles of several IDE's. There's just one thing I fail to understand:
You have your project with CMake files and each developing person generates his own project from it for his/her favourite IDE. But how do you nicely merge those things back into the general (CMake) project folder again? Or do you need to manually sync the changed files everytime again, by copying them in the general project folder again?
I hope you guys can help give me a solution to this problem!
The generated project files are build artifacts, just like object files. They aren't portable to other systems, and should never be manually modified or checked into a version control system. Instead, check in the CMakeLists.txt
file. Note that these generated project files refer directly to the source files, and can be used not only to build, but also to edit your source files.
Changes to the project are made directly to CMakeLists.txt
(for example adding a new file, or linking to a new library). If changes are needed to support a certain development environment, you make those carefully, and test to be sure you haven't broken the build on someone else's environment. For example, IF(WIN32)
or IF(UNIX)
allows basic conditionals on system type. Many more are possible based on exact build tool, system architecture, presence or absence of libraries or other files, etc.
It is highly recommended to build "out-of-source", so that build artifacts (including generated project files) do not touch the source tree at all. This keeps your source control software clean, and allows multiple builds for multiple compilers out of the same source.