[CMake] macro withunexpected results

ope ope-devel at gmx.de
Fri Aug 24 15:06:25 EDT 2007


>> >> macro(ADD_SUBDIRECTORIES dirlist)
>> >>   set(prefix " + ")
>> >>   MESSAGE(STATUS "add_subdirectories: ${ARGN}")
>> >>   foreach(subdir ${dirlist})
>> >>     MESSAGE(STATUS "${prefix}${subdir}")
>> >>     add_subdirectory(${subdir})
>> >>   endforeach(subdir ${dirlist})
>> >> endmacro(ADD_SUBDIRECTORIES)
>> >>
>> >> using this gets:
>> >>
>> >> ...
>> >> -- Scanning for sub projects in extra:
>> >> -- Adding est;boost;threadpool
>> >> -- add_subdirectories: boost;threadpool
>> >> --  + est
>> >> ...
> >
> > The macro has one argument "dirlist" which gets the first argument: est.
> > The remaining arguments go into ARGN. You are iterating over the first
> > argument only.

Thanks, I changed to:

macro(ADD_SUBDIRECTORIES)
  set(prefix " + ")
  MESSAGE(STATUS "add_subdirectories: ${ARGN}")
  foreach(subdir ${ARGN})
    MESSAGE(STATUS "${prefix}${subdir}")
    add_subdirectory(${subdir})
  endforeach(subdir ${ARGN})
endmacro(ADD_SUBDIRECTORIES)

and got:

-- Scanning for sub projects in extra:
-- Adding est;boost;threadpool
-- add_subdirectories: est;boost;threadpool
--  + est
--  + boost
-- Scanning ...

The last is missing, why?

Thanks,
Olaf





More information about the CMake mailing list