replace SUBDIRS() with ADD_SUBDIRECTORY() in CMakeLists.txt #18633

Closed
opened 2009-04-27 22:42:14 +02:00 by Alexander Neundorf · 6 comments

%%%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.
Example:

src/CMakeLists.txt:

subdirs(somedir)
set(FOO "foo")

src/somedir/CMakeLists.txt

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.

Alex
%%%

%%%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. Example: src/CMakeLists.txt: subdirs(somedir) set(FOO "foo") src/somedir/CMakeLists.txt 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. Alex %%%

Changed status to: 'Open'

Changed status to: 'Open'

%%%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.

Alex
%%%

%%%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. Alex %%%

%%%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.

Alex
%%%

%%%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. Alex %%%

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

closing.%%%

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

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'

%%%This patch has been applied to blender 2.5.%%%

%%%This patch has been applied to blender 2.5.%%%
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#18633
No description provided.