Page 1 of 1

CMakeLists.txt

Posted: Sun Nov 02, 2008 10:01 am
by 1337
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? ;)

Posted: Mon Nov 10, 2008 4:55 pm
by 1337
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.