CMake help wanted

Altren

17-05-2009 08:22:43

I decided to start moving to CMake long time ago, but had no free time for it. Now I have time, but looks like CMake isn't so easy - looked through Ogre CMake files and realized that without experience with CMake it can take many of time. Looks like some files can be used without changes (from Ogre/Cmake/Packages folder), and few changes (from Ogre/Cmake/Utils folder), but there's lots of other files and I don't even know where to start from :?

I also tried to use some converting scripts that found in CMake wiki, but all this scripts is for simple projects and am2cmake is highly integrated with Kde.

So I need help :roll: Of course better if someone will create something that works : compiles demos and creates libraries. But any help where to start from and what to do would be also good.

jacmoe

17-05-2009 09:13:26

I quickly put together the (initial) CMake build system for Ogitor. Take a look at that. It's easier to get an overview of.
Thought CMake was going to be a major undertaking, but it wasn't . :)

andrewfenn

03-06-2009 02:52:05

Do you still need help with this?

Archwyrm

03-06-2009 04:07:00

I'll second that question. CMake is a nice build system and a whole lot simpler than automake/autotools, so it should not be too hard to learn. We have been happily using it in our project (along with MyGUI!) for a long time now. While I can't offer direct help (we have been trying to get a release out the door for months), I would be happy to help with advice and any problems encountered.

Anyway, MyGUI's needs are a bit complicated but nothing that CMake can't easily handle. First, if you have not already, you should look through the Syntax Intro and simple example. Then basically you need a CMakeLists.txt in the root of your directory and one in each sub-project, which for MyGUI probably means one for the main lib, one for each demo, one for the layout editor and for the example plugin too probably. All of these depend on the lib project, of course. Then inside the main script you need to make sure you have the necessary deps (OGRE and freetype). There is a built-in script in CMake for freetype, but you will need one for OGRE (ours is pretty good and was based off one from Thermite 3D). Possibly there is an official OGRE script for finding it now, I don't know. Lastly, the main script will use add_subdirectories() to call the subsequent scripts which do the real work. Configuring installation is the last step, which I have not yet done personally, but it looks pretty straightforward.

That is it in a nutshell. There is certainly more than one way to setup your build system using CMake. The best thing to do is to refer to examples of working systems, particularly ones with similar needs. You might look at Bullet's which has libraries and then demos that depend on the libraries (similar situation to MyGUI).

jacmoe

03-06-2009 04:18:03

Ogre's CMake scripts are Public Domain now. :)
CABAListic gives a quick run-down on how to use them in your own projects here:
http://www.ogre3d.org/forums/viewtopic.php?f=5&t=50299&p=342552#p342552

Archwyrm

03-06-2009 05:05:00

Ah, that is good to hear. Ours/Thermite's is BSD licensed, which isn't too bad though. The additional steps for getting the external scripts up and running should be useful for whoever starts the MyGUI script (or has started it).

garvek

03-06-2009 07:28:49

I join others, CMake rocks.
I start to have some (little) experience with CMake, if you're interrested I can try something. Which SVN revision should I use to start from ? 1900 ?

Altren

05-06-2009 19:40:40

Do you still need help with this?Well, we already have one man that said that he'll help us, so I'll say no for now, because I don't know what we actually need :)
2 Archwyrm Thank you, I took your script, it looks much smaller and more simple than FindOGRE.cmake script from Ogre because it looks like it have too much functionality.
2 jacmoe Yeah, 1st thing that I was lookin at was Ogre CMake scripts, I copied many scripts from it.
I start to have some (little) experience with CMake, if you're interrested I can try something. Which SVN revision should I use to start from ? 1900 ? Well, if you want to do something than use latest revision, but you should know that it's bad place to learn CMake, because MyGUI build system not so simple :) . I was saying to use r1900 exactly because of partially broken build system (it works in Debug for windows now and seriously broken for linux) and I'm fixing it because I want to set up CMake instead.

garvek

06-06-2009 13:43:41

I've taken quickly a look at the current CMake files in the latest SVN. It seems that you're quite advanced on it :) I have a few comments (no pretention though, I'm used to CMake since only 6 months):

- why do you have dependencies to DirectX ? Unless you rebuild parts of Ogre or added platform-dependant features, I'm not sure it is needed. Personnaly I compile MyGUI since almost 6 months and don't have any DirectX SDK installed under Windows. I used customized version of the VC9 project files. (Under linux the usual stuff is fine, but I admit that I didn't test to build since several weeks).

- I'm not sure about it, but why do you have references to Ogre files in install stage ? I didn't find them in the repository anyway, perhaps it is in-progress copy & adapt stuff from Ogre

- I see references to configure / preprocess stuff ( .in files, etc ). Perhaps it is also work in progress but maybe these parts can now be handled by CMake ? Else it would make something a little ... hybrid (I mean, CMake is supposed to generate most of the build scripts).

Altren

06-06-2009 16:52:42

Actually I'm still bad in CMake, all that I did was mainly copy pasted from Ogre. Some parts was copied without even looking through.
- why do you have dependencies to DirectX ? Unless you rebuild parts of Ogre or added platform-dependant features, I'm not sure it is needed. Personnaly I compile MyGUI since almost 6 months and don't have any DirectX SDK installed under Windows. I used customized version of the VC9 project files. (Under linux the usual stuff is fine, but I admit that I didn't test to build since several weeks).Now you can use MyGUI with Ogre or DirectX, both is optional. We implementing renderer based on pure DirectX.
- I'm not sure about it, but why do you have references to Ogre files in install stage ? I didn't find them in the repository anyway, perhaps it is in-progress copy & adapt stuff from Ogre

- I see references to configure / preprocess stuff ( .in files, etc ). Perhaps it is also work in progress but maybe these parts can now be handled by CMake ? Else it would make something a little ... hybrid (I mean, CMake is supposed to generate most of the build scripts).
Dumb copypasting from Ogre CMake scripts :oops: I don't know how it should be.

Altren

08-06-2009 05:42:27

Thing goes much better now. There's brunch called cmake_port in repository with working CMake, all demos and tools already works. Looks like all help that we need is 1)testing it and 2)Mac OS support.

Archwyrm

09-06-2009 06:22:14

After a few fixes everything built cleanly for me (patch below). I am using Arch Linux and cmake 2.6.3.

First off, I don't have Doxygen installed on this machine and generating documentation ought to be optional, so I would suggest making an option() for it. For now I have just wrapped the add_subdirectory() with an if to make sure that Doxygen was found. Also your current options available on the commandline might be more friendly if you stripped off the leading MYGUI_ (yeah, I know variable name clobbering and all, just be careful ;)).

Second, you set options for building the two rendering systems but didn't ever use them. I have fixed that. My changes also jump over and delete the extra CMakeLists.txt under RenderingSystem/DirectX/ and RenderingSystem/Ogre/. You don't need these.

Lastly, you will probably want to make some of the deps required. Probably based on what options were used. Right now if a dependency is not found, CMake won't bail out, so you could go on to make and then find out that you are missing headers and whatnot (which is a lot uglier). Making something required is quite easy, e.g.: find_package(Freetype REQUIRED)

Oh, and it seems there is still some OGRE specific stuff lying around (not 100% sure on that). It would be good to cleanup to make the build system more maintainable. Overall though, good job! Nice to see MyGUI using a build system that doesn't drive you insane to look at. :)


Index: RenderSystems/DirectX/CMakeLists.txt
===================================================================
--- RenderSystems/DirectX/CMakeLists.txt (revision 2030)
+++ RenderSystems/DirectX/CMakeLists.txt (working copy)
@@ -1 +0,0 @@
-add_subdirectory(DirectXRenderSystem)
Index: RenderSystems/Ogre/CMakeLists.txt
===================================================================
--- RenderSystems/Ogre/CMakeLists.txt (revision 2030)
+++ RenderSystems/Ogre/CMakeLists.txt (working copy)
@@ -1 +0,0 @@
-add_subdirectory(OgreRenderSystem)
Index: RenderSystems/CMakeLists.txt
===================================================================
--- RenderSystems/CMakeLists.txt (revision 2030)
+++ RenderSystems/CMakeLists.txt (working copy)
@@ -1,2 +1,7 @@
-add_subdirectory(DirectX)
-add_subdirectory(Ogre)
+if(MYGUI_BUILD_RENDERSYSTEM_D3D9)
+ add_subdirectory(DirectX/DirectXRenderSystem)
+endif(MYGUI_BUILD_RENDERSYSTEM_D3D9)
+
+if(MYGUI_BUILD_RENDERSYSTEM_OGRE)
+ add_subdirectory(Ogre/OgreRenderSystem)
+endif(MYGUI_BUILD_RENDERSYSTEM_OGRE)
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt (revision 2030)
+++ CMakeLists.txt (working copy)
@@ -183,8 +183,10 @@
add_subdirectory(UnitTests)
endif ()

-# Install documentation
-add_subdirectory(Docs)
+# Generate documentation
+if(DOXYGEN_FOUND)
+ add_subdirectory(Docs)
+endif(DOXYGEN_FOUND)

# Install media files
#if (MYGUI_INSTALL_MEDIA)

Altren

09-06-2009 08:25:25

Thank you - applied your changes.
About required packages: actually there's no really required packages - all is optional, we just need finish scripts for not building if something required for demos wasn't found.

AndiNo

13-06-2009 18:16:13

Sorry for being a bit noobish on this part (only used CMake once), but does this mean we now can generate working project files for MyGUI with CodeBlocks?

Archwyrm

13-06-2009 23:12:12

I have never used CodeBlocks, but you should be able to like so: cmake . -G CodeBlocks

For more information, see the cmake man page.

Altren

14-06-2009 12:45:56

Yes, now you can have up-to-date Code::Blocks project files. I tried it few days ago, looks like it already works fine.