CMake & Premake builds

1,269 views
Skip to first unread message

Cam

unread,
Apr 18, 2010, 12:01:27 AM4/18/10
to recastnavigation
I was trying to update an old thread I'd started about using CMake to
build Recast but it seems the Google Groups won't let me. The original
thread was http://groups.google.co.nz/group/recastnavigation/browse_thread/thread/bcc16dfd8cada17c

Anyway, I'd done a bit more with CMake since my last post and I've
also been playing around with Premake. I
use Recast for my build experiments, since it doesn't have any Linux
build and I figure it might help Mikko out if he's interested in
CMake, etc.

I've played around with two different ways of generating CMake builds.
One generates separate project files and one which generates a single
project file for RecastDemo. Both implementations can be found on my
github, the multi-project one is at
http://github.com/bitshifter/recastnavigation/blob/cmake/CMakeLists.txt
(plus included files) and the single project one is at
http://github.com/bitshifter/recastnavigation/blob/cmake/RecastDemo/Build/CMakeLists.txt

In addition to playing with CMake I was also interested in Premake
(http://industriousone.com/premake). The design goals of CMake and
Premake are slightly different. They are both build generators but
CMake is intended to be run by users to create a build for their
platform whereas Premake is intended to be run by the project
maintainer to generate different platform build files for distribution
distribute. With CMake if you are running on Mac you can't generate
Windows VS builds. With Premake you can. So the advantage of Premake
is a project maintianer could potentially use it to generate all their
builds for distribution with their project. I have a Premake branch on
my github too at http://github.com/bitshifter/recastnavigation/tree/premake/Build/.
The premake4.lua file is the main config file and the generate_all.sh
generates Linux Makefile, XCode and VS2008 builds.

Premake is definitely less mature than CMake but it seems more
promising in some ways. For one they've started adding support for
Xbox 360 and PS3 builds. On the down side the generated folder
structure in the VS project is not ideal and I have little control
over it. I haven't been able to test XCode.

A lot of studios use their own internal build systems anyway so I
don't think it's possible to make something that works for everyone.
However, it is good if people can grab Recast (or any project) and
build it on their platform of choice with minimal hassle.


--
Subscription settings: http://groups.google.com/group/recastnavigation/subscribe?hl=en

Mikko Mononen

unread,
Apr 18, 2010, 11:37:38 AM4/18/10
to recastna...@googlegroups.com
Hi,

Thanks! I totally agree that it would be really good to be able to
compile the demo on any platform with ease. Premake sounds a tad more
interesting to me, I'll take a look at those project files.

--mikko

Mikko Mononen

unread,
Apr 18, 2010, 12:49:37 PM4/18/10
to recastna...@googlegroups.com
I did a quick test to try to use Premake and Cmake. I was unable to
run premake at all, the osx binary probably links to some dlib which I
don't have. I also tried to give Cmake a try, but either the program
or the operator failed :) I simply tried "cmake .; make", it did
create some build files, but make failed at linking with:

Linking CXX executable RecastDemo
Undefined symbols:
"_main", referenced from:
start in crt1.10.5.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[2]: *** [RecastDemo] Error 1
make[1]: *** [CMakeFiles/RecastDemo.dir/all] Error 2
make: *** [all] Error 2

As time permits, I will investigate this more.


--mikko

Cam

unread,
Apr 18, 2010, 4:38:48 PM4/18/10
to recastnavigation
That's a shame premake didn't work. You could try their help forums
and see if they have any explaination http://industriousone.com/forums/premake/help.

As for the CMake problem, I haven't had access to a Mac so haven't
been able to test. I am probably missing a few important things. For
one Ihaven't been including the SDLmain.m to the list of files which
you need on Mac. There are probably other issues I don't know about.

Come to think of it, there are some Macs with Xcode on them at my work
so I'll try taking a look on one of them.

On Apr 19, 4:49 am, Mikko Mononen <memono...@gmail.com> wrote:
> I did a quick test to try to use Premake and Cmake. I was unable to
> run premake at all, the osx binary probably links to some dlib which I
> don't have. I also tried to give Cmake a try, but either the program
> or the operator failed :) I simply tried "cmake .; make", it did
> create some build files, but make failed at linking with:
>
> Linking CXX executable RecastDemo
> Undefined symbols:
>   "_main", referenced from:
>       start in crt1.10.5.o
> ld: symbol(s) not found
> collect2: ld returned 1 exit status
> make[2]: *** [RecastDemo] Error 1
> make[1]: *** [CMakeFiles/RecastDemo.dir/all] Error 2
> make: *** [all] Error 2
>
> As time permits, I will investigate this more.
>
> --mikko
>
> On Sun, Apr 18, 2010 at 6:37 PM, Mikko Mononen <memono...@gmail.com> wrote:
> > Hi,
>
> > Thanks! I totally agree that it would be really good to be able to
> > compile the demo on any platform with ease. Premake sounds a tad more
> > interesting to me, I'll take a look at those project files.
>
> > --mikko
>
> > On Sun, Apr 18, 2010 at 7:01 AM, Cam <cameron.h...@gmail.com> wrote:
> >> I was trying to update an old thread I'd started about using CMake to
> >> build Recast but it seems the Google Groups won't let me. The original
> >> thread washttp://groups.google.co.nz/group/recastnavigation/browse_thread/threa...
>
> >> Anyway, I'd done a bit more with CMake since my last post and I've
> >> also been playing around with Premake. I
> >> use Recast for my build experiments, since it doesn't have any Linux
> >> build and I figure it might help Mikko out if he's interested in
> >> CMake, etc.
>
> >> I've played around with two different ways of generating CMake builds.
> >> One generates separate project files and one which generates a single
> >> project file for RecastDemo. Both implementations can be found on my
> >> github, the multi-project one is at
> >>http://github.com/bitshifter/recastnavigation/blob/cmake/CMakeLists.txt
> >> (plus included files) and the single project one is at
> >>http://github.com/bitshifter/recastnavigation/blob/cmake/RecastDemo/B...
>
> >> In addition to playing with CMake I was also interested in Premake
> >> (http://industriousone.com/premake). The design goals of CMake and
> >> Premake are slightly different. They are both build generators but
> >> CMake is intended to be run by users to create a build for their
> >> platform whereas Premake is intended to be run by the project
> >> maintainer to generate different platform build files for distribution
> >> distribute. With CMake if you are running on Mac you can't generate
> >> Windows VS builds. With Premake you can. So the advantage of Premake
> >> is a project maintianer could potentially use it to generate all their
> >> builds for distribution with their project. I have a Premake branch on
> >> my github too athttp://github.com/bitshifter/recastnavigation/tree/premake/Build/.

Cam

unread,
Apr 18, 2010, 9:41:29 PM4/18/10
to recastnavigation
I had quick go on a Mac in my lunch break. Premake ran OK for me. The
Mac I was using was running MacOSX 10.6.2. If you are on 10.5 I guess
that may be why that compiled binary doesn't work for you?

I'll have a look at the Mac compile issues later today.

On Apr 19, 8:38 am, Cam <cameron.h...@gmail.com> wrote:
> That's a shame premake didn't work. You could try their help forums
> and see if they have any explainationhttp://industriousone.com/forums/premake/help.

Mikko Mononen

unread,
Apr 19, 2010, 3:14:32 AM4/19/10
to recastna...@googlegroups.com
Including SDLMain.m, seems to make it compile just fine, but... :) but
executing it seems to fail. I think the exe assumes that it would sit
inside the .app package structure. I'll see if I can make premake to
work.

--mikko

Cam

unread,
Apr 19, 2010, 7:17:33 AM4/19/10
to recastnavigation
I've updated the premake4.lua and CMakefiles.txt on my github. I
managed to get the CMake version to run on Mac if I moved it to the
right directory it would run. For the CMake builds on Windows I had a
post-build copy step to copy the compiled exe to the RecastDemo/Bin
directory. I haven't worked out a better way of doing that.

As for Premake, I ran out of time. After adding the SDLMain.m into the
Mac OS X builds I needed to work out the proper way of including SDL
and Open GL. It looks like I should be able to add SDL.framework etc
to the file list to get it to work.

You could try grabbing the Premake source and building it locally, you
might have more success. There are Xcode and Makefile builds for Mac.

On Apr 19, 7:14 pm, Mikko Mononen <memono...@gmail.com> wrote:
> Including SDLMain.m, seems to make it compile just fine, but... :) but
> executing it seems to fail. I think the exe assumes that it would sit
> inside the .app package structure. I'll see if I can make premake to
> work.
>
> --mikko
>
> On Sun, Apr 18, 2010 at 11:38 PM, Cam <cameron.h...@gmail.com> wrote:
> > That's a shame premake didn't work. You could try their help forums
> > and see if they have any explainationhttp://industriousone.com/forums/premake/help.

Mikko Mononen

unread,
Apr 19, 2010, 7:21:59 AM4/19/10
to recastna...@googlegroups.com
I'll try the new cmake scripts, I tried copying the executable created
by cmake to the bin folder, but it did not work. Premake4 seems to
need premake4 to build it :( It looks like the exe was build for OSX
10.6 (snow leo), and I have 10.5, and there was some new dynamic
library loading thing added in between. I posted something on the
premake discussion boards, let's see what happens.

Thanks for the help so far. I feel like total noob when it comes to
tinkering with build systems :)


--mikko

Cam

unread,
Apr 19, 2010, 7:46:27 AM4/19/10
to recastnavigation
The BUILD.txt for Premake claimed you needed premake4 to build it, but
in the build folder there are actually a bunch of pre-generated build
configs, including Xcode. That was in the premake-4.2.1-src.zip from
the site's download page.

I think I'll have to spend some more time on the Mac at work to get
this all going. It's a shame I can't run Mac OS X in a VM!

Recast has been proving very useful at work, so I'm glad I can help
out in some way.

Mikko Mononen

unread,
Apr 19, 2010, 8:00:40 AM4/19/10
to recastna...@googlegroups.com
Yay! Got premake4 to work, maybe. I creates the projects, but the
files are missing except SDLMain.m, which is there but has wrong path
(recastnavigation/RecastDemo/RecastDemo/Source/SDLMain.m) :). I try to
mess around myself a bit to see if I can get it to work. I hope it
supports special build flags per platform, since I have quite a few
flags set so that I can have warnings as close to VC/gcc as possible.


--mikko

Cam

unread,
Apr 19, 2010, 8:21:53 AM4/19/10
to recastnavigation
Maybe my change to add SDLMain.m to files actually managed to
overwrite the file list. According to the docs that shouldn't be the
case but I have found it a little temperamental.

There are some predefined flags described at http://industriousone.com/flags.

If they don't offer enough control you can also specify command line
arguments for the compiler with http://industriousone.com/buildoptions
and http://industriousone.com/linkoptions. I'm using those for the
Linux builds so they can call pkg-config to get include and lib paths
for GL and SDL.

Cam

unread,
Apr 21, 2010, 2:41:41 AM4/21/10
to recastnavigation
I've managed to get premake generating working Xcode project files
now. It compiles and debugs on Mac!

I have committed the working premake4.lua in the premake branch on my
github repository. I haven't actually committed the working Xcode
projects, but you should be able to generate them yourself. You may
want to nuke any existing project in Build/Xcode before generating.

Hopefully this works for you too.

Mikko Mononen

unread,
Apr 21, 2010, 9:46:06 AM4/21/10
to recastna...@googlegroups.com
Great!

I was able to sort out the binaries issue with the premake author too.
I have following extra warnings enabled for xcode, so that I can catch
some general gcc, and vc warnings while adding features:

OTHER_CPLUSPLUSFLAGS = $(OTHER_CFLAGS) -Wreorder -Wsign-compare -Wall

Also, I have warnings level set to max in VC.

I think it is time for me to remove some proto and test .cpp files
from the folders and star trying to use the new system.

One more question, does that script automatically also add the icon
and .nib files for xcode?


--mikko

Cameron Hart

unread,
Apr 21, 2010, 4:16:11 PM4/21/10
to recastna...@googlegroups.com
It should be easy enough to get all the warnings right.

Regarding temp files in the source tree, at the moment I'm using wildcards to add files. This means of course it will pick up anything else in the directories. It may be better to list the files explicitly to avoid unintended files being added. That would mean of course you'd have to remember to update the file list. What is your preference?

The icons don't get added automatically, but I think it will be possible to add them. I'll look into it. What does the .nib file do?

Mikko Mononen

unread,
Apr 21, 2010, 4:25:37 PM4/21/10
to recastna...@googlegroups.com
I prefer wildcards. I should not have those extra file laying in there
in the first place.

I think the .nib file is something like the resources files on
windows. Not sure which ones xcode pics automatically. Another xcode
specific is the plist file too.

--mikko

Cam

unread,
Apr 21, 2010, 4:31:45 PM4/21/10
to recastnavigation
I've added the extra warnings, uploaded to github. I'll look into
adding the other Xcode resources.

Cam

unread,
Apr 24, 2010, 2:07:18 AM4/24/10
to recastnavigation
I've updated my github with some more premake changes:

* Xcode build now includes resources including Info.plist, Icon.icns
and the English.lproj files
* The --to=<directory> is used to tell premake where to generate
build files to, this is what premake does and it seemed more flexible
than hard coding
* Updated generate_all.sh to use --to, it now generates to Linux, VC9
and Xcode directories
* Regenerated all builds

The Xcode generated app now has the correct icon. There were a couple
of bugs in Premake4 with adding resources to Xcode. For one it doesn't
know what a .icns file is and tries to show it as text in Xcode, it
seemed to use the icon correctly in the built executable though. The
English.lproj directory had to be in the same directory as the
premake4.lua file. I think this is because it treats that path as
relative to something, I wasn't sure what was going wrong there.

I'll contact the author of Premake about the bugs I found sometime.


On Apr 22, 8:25 am, Mikko Mononen <memono...@gmail.com> wrote:
> I prefer wildcards. I should not have those extra file laying in there
> in the first place.
>
> I think the .nib file is something like the resources files on
> windows. Not sure which ones xcode pics automatically. Another xcode
> specific is the plist file too.
>
> --mikko
>
> On Wed, Apr 21, 2010 at 11:16 PM, Cameron Hart <cameron.h...@gmail.com> wrote:
> > It should be easy enough to get all the warnings right.
>
> > Regarding temp files in the source tree, at the moment I'm using wildcards
> > to add files. This means of course it will pick up anything else in the
> > directories. It may be better to list the files explicitly to avoid
> > unintended files being added. That would mean of course you'd have to
> > remember to update the file list. What is your preference?
>
> > The icons don't get added automatically, but I think it will be possible to
> > add them. I'll look into it. What does the .nib file do?
>
> > On 22 April 2010 01:46, Mikko Mononen <memono...@gmail.com> wrote:
>
> >> Great!
>
> >> I was able to sort out the binaries issue with the premake author too.
> >> I have following extra warnings enabled for xcode, so that I can catch
> >> some general gcc, and vc warnings while adding features:
>
> >>   OTHER_CPLUSPLUSFLAGS = $(OTHER_CFLAGS) -Wreorder -Wsign-compare -Wall
>
> >> Also, I have warnings level set to max in VC.
>
> >> I think it is time for me to remove some proto and test .cpp files
> >> from the folders and star trying to use the new system.
>
> >> One more question, does that script automatically also add the icon
> >> and .nib files for xcode?
>
> >> --mikko
>
Reply all
Reply to author
Forward
0 new messages