[CMake] CMake performance question

Alexander Neundorf a.neundorf-work at gmx.net
Fri Oct 20 02:49:56 EDT 2006


Hi,

I have a question how CMake behaves for some special (but in my case very common) construction. I have two macros, each of them using ARGN for dealing with an unspecified number of arguments:

#01 macro(_do_internal)
#02    foreach(_current ${ARGN})
#03       message(STATUS "${_current})
#04    endforeach(_current ${ARGN})
#05 endmacro(_do_internal)
#06
#07 macro(do_foo)
#08    if (UNIX)
#09       add_executable(blub ${ARGN})
#10    else (UNIX)
#11       add_library(blub ${ARGN})
#12    endif (UNIX)
#13    _do_internal(${ARGN})
#14 endmacro(do_foo)
#15
#16 set(srcs main.cpp process.cpp)
#17 do_foo(${sercs})

So let's say we're on UNIX, then what happens exactly ?
I think:
#16: the line is parsed and a vector containing the arguments is created, which is handed the cmSetCommand. This turns the vector into a string.
#17: the line is parsed, ${srcs} is expanded to the string in srcs and parsed again into a vector.
#08: it evaluates to true, so we continue there.
#09: from the vector ARGN a string is constructed, which is the parsed and again turned into a vector which is handed to add_library
#11: although we don't really go there, is ARGN still expanded and parsed into a vector ?
#13: ARGN is again converted from a vector into a string and then parsed back into a vector
#02: ARGN is again converted from a vector to a string which is turned into vector which is then iterated.

Do I understand correctly ? 
I found that for us quite a lot of time seems to be spent in parsing. I'm thinking about using lists more to speed this up.

Bye
Alex

-- 
GMX DSL-Flatrate 0,- Euro* - Überall, wo DSL verfügbar ist!
NEU: Jetzt bis zu 16.000 kBit/s! http://www.gmx.net/de/go/dsl


More information about the CMake mailing list