CMakeLists.txt

A place to discuss everything about the Orxonox framework.

Moderator: PPS-Leaders

Post Reply
User avatar
1337
Baron Vladimir Harkonnen
Posts: 521
Joined: Wed Oct 10, 2007 7:59 am

CMakeLists.txt

Post by 1337 » Sun Nov 02, 2008 10:01 am

When we restarted orxonox with CMake, we put such a CMakeLists.txt (CMLs) in every folder. That forced us to create a library for every folder, so we changed things.

Half a year or so ago I was looking for a solution with CMLs in every folder, but just one library and didn't come up with something.
In the meantime, a lot of source files have been written into src/orxonox/CMLs and it's not very clear anymore.

Is there any way to have a CMLs in every folder after all? Maybe with a CMake macro, I don't know.
I'm asking now because we've caught a PPS student with a large knowledge about CMake, right Adi? ;)
http://www.xkcd.com/
A webcomic of romance, sarcasm, math, and language.

User avatar
1337
Baron Vladimir Harkonnen
Posts: 521
Joined: Wed Oct 10, 2007 7:59 am

Post by 1337 » Mon Nov 10, 2008 4:55 pm

Issue resolved: CMake does have a lot of catches, but finally with the Cache I managed to meet my wishes.

Consider you want to include files according to the following structure:
orxonox
objects
worldentities

Your CMLs in orxonox folder folder should look like this:

Code: Select all

SET( SRC_FILES FooBar.cc FooBar2.cc )
ADD_SOURCE_DIRECTORY(SRC_FILES objects)
In orxonox/objects, the CMLs looks a little bit different:

Code: Select all

SET( SRC_FILES BarFoo.cc BarFoo2.cc )
ADD_SOURCE_DIRECTORY(SRC_FILES worldentities)
# Do this after ADD_SOURCE_DIRECTORY !
ADD_SOURCE_FILES(SRC_FILES)
And for the third CMLs in orxonox/object/worldentities:

Code: Select all

SET( SRC_FILES AsdfBlah.cc AsdfBlah2.cc )
ADD_SOURCE_FILES(SRC_FILES)

Note that variables in subdirectories are in a completely separate set. You cannot override any variable in the parent directory and vice versa.

I have applied that concept to all our own folders in the trunk.
http://www.xkcd.com/
A webcomic of romance, sarcasm, math, and language.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests