Page MenuHome

replace SUBDIRS() with ADD_SUBDIRECTORY() in CMakeLists.txt
Closed, ArchivedPublicPATCH


I had a look at the cmake files in blender and noticed that the SUBDIRS() command is used instead of the newer ADD_SUBDIRECTORY() command.
The main difference between the two is that ADD_SUBDIRECTORY() is processed
immediately, while the directories added with SUBDIRS() are processed after
everything else in the CMakeLists.txt has been processed. This is usually not
what one would expect, so using ADD_SUBDIRECTORY() is usually better.


set(FOO "foo")


message(STATUS "FOO: ${FOO}")


With subdirs() the message() in the subdirectory will print "foo", even although FOO is set _after_ the subdirs() command.
When replacing the subdirs() in this example with add_subdirectory() FOO will be empty in somedir/CMakeLists.txt, as one would expect if everything is processed in order.

The attached changes all SUBDIRS() in blender to ADD_SUBDIRECTORY()
Please apply if you think it makes sense.


Event Timeline

There was a bug in subdirs.diff, one SUBDIRS() with two directories was translated to only one ADD_SUBDIRECTORY(). subdirs-2.diff does it correctly.


diff reports that the created binary blender executables differ. At least they have exactly the same size in bytes.
When comparing the complete build log for both, the only difference is that the order of building a few source files has changed, nothing else. So maybe that changed order is the only difference.
I did a "make blender" and some grepping to remove the progress reporting to get the logs.


applied to blender 2.5, this will become trunk soon.
Thanks for the patch.


Campbell Barton (campbellbarton) changed the task status from Unknown Status to Unknown Status.Aug 24 2009, 12:01 PM

This patch has been applied to blender 2.5.