Build system

31 views
Skip to first unread message

mikusp

unread,
Oct 7, 2012, 10:49:42 AM10/7/12
to gamefro...@googlegroups.com
I read a little about CMake yesterday and put together a simple build system for our project. It includes a simple main.cpp file calling an al_init() function to test if you can compile a program that is using allegro. To build the executable file, open the project directory, make a new dir (for example build), open it and run "cmake ..". You can change a compiler used by CMake by setting the "CXX" environmental variable. For example, "CXX=/usr/bin/clang++ cmake .." will generate a Makefile that uses Clang to compile the project. After running cmake, build the executable file using make. If everything worked, a binary file should appear in bin/ subdirectory. It can be run, but it doesn't do anything interesting :)

DeusexConstantia

unread,
Oct 7, 2012, 3:32:00 PM10/7/12
to gamefro...@googlegroups.com
I added a quick and dirty linux detection which links the base library of allegro, so it now also builds on linux.

What's important to note for the Ubuntu Users is that allegro 5 doesn't use allegro-config to  show libs like Allegro 4 ( the one in the repository) but uses
pkg-config --libs , so for example when you want to link the base library ( allegro-5.0) you type pkg-config --libs allegro-5.0 and it returns  your linker flags ( -L/usr/local/lib -lallegro )

mikusp

unread,
Oct 7, 2012, 3:42:38 PM10/7/12
to gamefro...@googlegroups.com
I should have clarified that I'm using Linux and it was building fine for me. Are you sure that the rule for adding "-lallegro" should be wrapped in IF(WIN32)? Also if it's possible, maybe rule for linking against Allegro should call pkg-config?

DeusexConstantia

unread,
Oct 7, 2012, 3:57:37 PM10/7/12
to gamefro...@googlegroups.com
Hm ok, I just assumed you were using windows because it didn't build for me.

Yes, letting it call pkg-config would be smarter, this is just something I hacked together after a bit of googling so I could compile.

-lalleg could be the option for Allegro 4.

DeusexConstantia

unread,
Oct 7, 2012, 4:20:42 PM10/7/12
to gamefro...@googlegroups.com
So I rewrote the thing, commented out the allegro 4 thing and my linking now uses pgk_check_modules which is cmakes piggyback on pgk-config.

Should I open a pull request or just push it directly to the repo?

mikusp

unread,
Oct 7, 2012, 4:29:05 PM10/7/12
to gamefro...@googlegroups.com
That version builds correctly. It will be good if somebody else test it on their system, but it should be fine.

I'd say just push it to the repo.

DeusexConstantia

unread,
Oct 7, 2012, 4:59:15 PM10/7/12
to gamefro...@googlegroups.com
Hm, I can't seem to push to the progether repo. Is there something I have to setup after cloning it? I only see a read-only link on the github page as well-

Freakazo

unread,
Oct 8, 2012, 5:45:59 AM10/8/12
to gamefro...@googlegroups.com


I worked some more on  the build scripts, I'll give a short description of all the files below

/CMakeLists.txt Simply sets some output dirs, includes the /src and the /tests dirs
/src/ the game engine files, compiles to a static library.
      /CMakeLists.txt includes platform independent files, detects platform and includes platform specific libraries and files
/src/arch/PLATFORM
     PLATFORM is the name of the operating system and contains OS specific files, for example display.h will be dependent on the OS used. This is a nice way of making it obvious what is platform specific.

/tests/ Contains all the test applications, will use it as a samples directory until we agree on a unit testing framework up and running.

To enable use of allegro, enable the CMake option USE_ALLEGRO

@deusexConstantia can you PM me your username so I can add you to the team on github? Should give you proper privileges.
Reply all
Reply to author
Forward
0 new messages