Cmake can really generate normal MSVC++ projects?

Get answers to all your basic programming questions. No Ogre questions, please!
Post Reply
User avatar
ahmedali
Gnome
Posts: 302
Joined: Fri Feb 20, 2004 8:52 pm
Location: Lahore, Pakistan

Cmake can really generate normal MSVC++ projects?

Post by ahmedali »

I wasted to days of learning Scons just to realize that it generates MSVS project which is hooked to Scons, no individual file compiling nor debugging...

I could just experiment with premake or cmake or any other project generator but can any one confirm that Cmake/Premake generate MSVS projects files with no frills or strings attached to its own build thingy... Can i really work on the generated project like a "NORMAL" msvc++ project..

It will really save some time...
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Cmake can really generate normal MSVC++ projects?

Post by jacmoe »

Of course. :)
Only caveat is that the paths are absolute, ie you can't move the project around.
So if you need to generate solution/projects for distrubution, you need to do those by hand, or premake/whatever.
But, yes: the purpose of CMake is to use native toolchains.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
ahmedali
Gnome
Posts: 302
Joined: Fri Feb 20, 2004 8:52 pm
Location: Lahore, Pakistan

Re: Cmake can really generate normal MSVC++ projects?

Post by ahmedali »

absolute path is ok, it can be get around. eventhough i find lua based premake simpler but because it seems cmake has larger userbase including ogre so im with cmake here.
jonim8or
Goblin
Posts: 287
Joined: Mon Dec 08, 2008 4:49 pm
x 10

Re: Cmake can really generate normal MSVC++ projects?

Post by jonim8or »

I must agree that Cmake can create MSVC++ projects. However, it depends on the structure of the cmake files, whether the generated visual studio project is easy to use or not. The Ogre Cmake files give a good, useful solution.

I'm not sure about the "hookedness" of the generated msvc project to cmake. That's because the idea is that the cmake project remains usable as a cmake project (so also for other compilers). Therefore adding source files, moving source files, etc. results in changes to the cmake files and re-running cmake. (at least, afaik)
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58
Contact:

Re: Cmake can really generate normal MSVC++ projects?

Post by CABAListic »

Yes, well, the generated VS solutions are not independent from CMake, but that's not the point. After all, if you wanted independent solutions, just create them. The solutions generated by CMake do call CMake to ensure they are up to date, and if you manually add new files or change build settings, then you will lose those changes when CMake is rerun. But that's exactly what you want if you use CMake, because then CMake is responsible for the build.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Cmake can really generate normal MSVC++ projects?

Post by jacmoe »

jonim8or wrote:I'm not sure about the "hookedness" of the generated msvc project to cmake. That's because the idea is that the cmake project remains usable as a cmake project (so also for other compilers). Therefore adding source files, moving source files, etc. results in changes to the cmake files and re-running cmake. (at least, afaik)
The projects are read-only. Don't touch them, touch the CMake script.
Normally, the ZERO_CHECK project will ensure that CMake is rerun if changes has been detected.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Re: Cmake can really generate normal MSVC++ projects?

Post by Klaim »

By the way, is there a relative-path alternative solution to CMake? I'm using custom python build scripts in my project but looks for a better solution...
starkos
Gnoblar
Posts: 1
Joined: Mon Dec 28, 2009 7:38 pm

Re: Cmake can really generate normal MSVC++ projects?

Post by starkos »

The files generated by Premake are not hooked to Premake in any way; they can be distributed and used without needing Premake installed.

Premake uses relative paths.

Like CMake, any changes to the project settings (defines, include paths, build flags, etc.) should be done in the Premake script, otherwise they will be overwritten the next time you generate the project files. The exception to the rule is files: if you use wildcards in your Premake script (i.e. *.h, *.cpp) then you can add files from the IDE without needing to update the script (I assume CMake is the same in this regard).

Since discussion about Premake is a bit off-topic for this forum, feel free send questions to the Premake forums at http://industriousone.com/forums/premake and I'll be glad to help out.

All that said, if you are creating something to be used with Ogre, and you plan to share it, you should probably use the same build system as Ogre.
ecoumans
Kobold
Posts: 39
Joined: Mon Sep 12, 2005 10:07 am
Location: San Francisco
x 4
Contact:

Re: Cmake can really generate normal MSVC++ projects?

Post by ecoumans »

With the right options, cmake can create normal MSVC projectfiles that use relative paths and that are independent of cmake. So you can distribute those projectfiles.
In a nutshell, you need those two options: CMAKE_SUPPRESS_REGENERATION and CMAKE_USE_RELATIVE_PATHS, and my patch for the cmake 2.8 issue with relative pdb file names. This patch been applied to their trunk to next version has it. If you are adventurous you can try out this precompiled patched binary cmake.exe, just copy it in your C:\Program Files (x86)\CMake 2.8\bin folder.

You can try the cmake pre-generated MSVC projectfiles as part of OgreKit.zip, using a recent SVN trunk version of Ogre 1.7 here:
http://code.google.com/p/gamekit/downloads/list

Thanks,
Erwin

By the way, premake seems a cool project too, it can create Xbox and PS3 project files (would be nice if it supported SPUs...)
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Re: Cmake can really generate normal MSVC++ projects?

Post by sinbad »

Interesting, I tried precisely these 2 options several times in the past and they've never worked for me (irrespective of the pdb issue), absolute paths were still littered around the project files. At what point in the project files did you define them?
ecoumans
Kobold
Posts: 39
Joined: Mon Sep 12, 2005 10:07 am
Location: San Francisco
x 4
Contact:

Re: Cmake can really generate normal MSVC++ projects?

Post by ecoumans »

Right at the start of the first CMakeLists.txt

it seems to work fine, I'm also using it for the upcoming Bullet physics releases.
Cheers,
Erwin
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Re: Cmake can really generate normal MSVC++ projects?

Post by sinbad »

Ok, ours was inside the project definition, maybe that's the problem.

Once the pdb fix is in the mainstream releases I'll look at this again for ours.
Post Reply