[CMake] Which variable stores all (sub) directories added sofar?

J.S. van Bethlehem j.s.van.bethlehem at astro.rug.nl
Thu May 19 07:27:38 EDT 2011


On 05/19/2011 12:47 PM, Rolf Eike Beer wrote:
> Am Donnerstag, 19. Mai 2011, 12:22:32 schrieb J.S. van Bethlehem:
>> Hello,
>>
>> Given that CMake errs when you try to some sub-directory twice using
>> add_subdirectory() I presume there is some variable that stores a list
>> of the directories that were added to the build sofar. But I can't find
>> the name of the variable. Does it exists (well... better would be: is it
>> visible to users) and if so, what is it called?
> I don't know the answer to your question, but:
>
> I use a global property to store the absolute path of all subdirectories added
> by a macro. If this macro encounters that the requested subdirectory is
> already in the list it simply does nothing.
>
> Eike
Hello Eike,

Thanks a lot for your reply. I have actually been thinking in the same 
direction. I have one problem though: how can you make a truly global 
variable in CMake? Whenever you do something to a variable in a 
directory that is added using add_subdirectory(), those changes don't 
propagate to the current directory
(well, one could use the PARENT_SCOPE option to set() in the 
sub-directory, but then I won't be able to test that sub-directory 
seperately because then CMake will err that there is no such scope)

How do you deal with this?

Greetsz, Jakob



More information about the CMake mailing list