Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    42
  • comments
    61
  • views
    33149

Converting project to CMake

Sign in to follow this  
jjd

2085 views

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.
Sign in to follow this  


4 Comments


Recommended Comments

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.

Share this comment


Link to comment
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!

Share this comment


Link to comment
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.


Share this comment


Link to comment
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!

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!