Converting project to CMake

posted in Necron00bicon
Published September 06, 2010
Advertisement
So I have taken a brief hiatus from the DOP project to work on a tiny game engine that I have been kicking around for while. It's pretty bad but it contains a bunch of stuff that I would like to make use of. In particular, I want to sort out the renderer so that I can actually display some of the cool results from the DOP project. But I'm currently working on several computers at the moment and I made the mistake of versioning my .sln and .vcproj files. I say 'mistake' because I think of these files as derived or intermediate files. They are not essential to the project, they are merely a convenience for working on the code, i.e. they allow me to use visual studio. But if I were to work on the project on linux they would be useless, even though the code would be fine. So I decided to learn CMake to break my dependence on these visual studio artifacts, and here I'm going to provide a little direction for anyone else walking down this path.

Read the rest at physicaluncertainty.com.
Previous Entry Lucky Me!
0 likes 4 comments

Comments

mightypigeon
I keep project and solution files in SCC repos, and I don't think it is a "mistake" as you put it. Things like the intellisense database, user settings etc. shouldn't be in there, but Visual Studio projects, Xcode projects, linux makefiles, etc, are fine to have in there. If you look at nearly any open source project, they'll have a separate folder for solution files for various versions of visual studio, makefiles and whatever else.
September 06, 2010 09:49 PM
void0
CMake is great. You could write up a project file for a shared or static library in just 2 lines of code:

project(test)
add_library(test SHARED test1.cpp test2.cpp test3.cpp)

Just replace SHARED with STATIC for static library. This simple code can be used to generate Unix makefiles, Visual Studio solution, Codeblocks project, etc. A little piece of heaven!
September 07, 2010 03:05 AM
jjd
Quote:Original post by mightypigeon
I keep project and solution files in SCC repos, and I don't think it is a "mistake" as you put it. Things like the intellisense database, user settings etc. shouldn't be in there, but Visual Studio projects, Xcode projects, linux makefiles, etc, are fine to have in there. If you look at nearly any open source project, they'll have a separate folder for solution files for various versions of visual studio, makefiles and whatever else.


Thanks for calling that point out. I was thinking this morning that calling it a mistake is probably a bit strong, but I still think it is a mistake if you are likely to be sharing the code, especially if it is multi-platform. Those projects do contain information about dependencies within the code and how the code should be build. However, when you put that information into the .sln and .vcproj files you are locking into a concrete implementation of those relationships. If someone else using a different version of visual studio wants to work on the project they are probably going to have to modify the project or solution files. This creates the risk that they will accidentally submit those files, introducing incompatible code for others. Cmake abstracts that information away so that someone (in theory) can use whatever build system they prefer without it affecting anything in the code base. If you don't have something equivalent to cmake then you have to duplicate information (like you describe for some open source projects), which also introduces a greater chance of introducing builds errors if all the different build files are not updated.


September 07, 2010 05:48 AM
jjd
Quote:Original post by void0
CMake is great. You could write up a project file for a shared or static library in just 2 lines of code:

project(test)
add_library(test SHARED test1.cpp test2.cpp test3.cpp)

Just replace SHARED with STATIC for static library. This simple code can be used to generate Unix makefiles, Visual Studio solution, Codeblocks project, etc. A little piece of heaven!


I wasn't too sure about cmake when I started with it this weekend, but I really like it now. There are some large mutli-platform projects I've worked on in the past where there was an ad-hoc system in place for the different build systems. How I wish we'd use cmake for that!
September 07, 2010 05:51 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

Advertisement