Bug 238456

Summary: Wrong order processing add_subdirectory
Product: [Applications] kdevelop Reporter: Nicolás Alvarez <nalvarez>
Component: Build tools: CMakeAssignee: kdevelop-bugs-null
Status: RESOLVED FIXED    
Severity: normal CC: aleixpol, dschie, kde, tobias_henkel
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:

Description Nicolás Alvarez 2010-05-22 04:13:16 UTC
Version:           4.0.60 (using KDevPlatform 1.0.60) (using 4.4.3 (KDE 4.4.3), Debian packages)
OS:                Linux (x86_64) release 2.6.32-3-amd64

There is a significant difference between CMake and KDevelop's parser in the order subdirectories are parsed.

Here is a very simple testcase that shows the wrong behavior:

CMakeLists.txt:
message(STATUS "before")
add_subdirectory(sub)
message(STATUS "after")

sub/CMakeLists.txt:
message(STATUS "this is the subdir")

CMake 2.8.1 output:
-- before
-- this is the subdir
-- after

KDevelop 4.0 output:
message: ("before")
message: ("after")
message: ("this is the subdir")

CMake parses subdirectories immediately upon seeing add_subdirectory, while KDevelop seems to put the directory in a pending queue, and only after it's done processing the current dir, it processes the queue.
Comment 1 Nicolás Alvarez 2011-07-20 02:09:59 UTC
I just found that (in official CMake) SUBDIRS() does add dirs to a queue to process them later, while ADD_SUBDIRECTORY() processes the subdir immediately. So the current KDevelop behavior for SUBDIRS is correct.
Comment 2 Aleix Pol 2017-03-04 00:01:27 UTC
We are not processing directories anymore