[CMake] Variable target name visible at the top level

Eric Noulard eric.noulard at gmail.com
Fri Oct 26 06:39:53 EDT 2012


2012/10/26 Vyacheslav Karamov <ubuntulist at yandex.ru>:

>
>>> How to handle this situation in a proper way?
>>
>> Define it at the scope it ought to be ?
>> or use
>>   set (snd_lib "sndlib" PARENT_SCOPE)
>>
>> but again I think your problems comes from the fact
>> your defined your var after add_subdirectory.
>>
> PARENT_SCOPE variable is visible only in a parent scope, not in a current
> one. But I need it in current scope, parent scope and scope above parent.

Then I guess you should try to use a global property or cached var.
Some example attached.

As you'll see both mechanism may achieve what you with varying bevahior.
If you want to learn the differences:

cmake --help-command get_property
cmake --help-command set_property
cmake --help-command set
-- 
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: multi-scope-var-or-props.tgz
Type: application/x-gzip
Size: 538 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20121026/09aa174c/attachment.bin>


More information about the CMake mailing list