[CMake] How to catch CMake Error get_directory_property

Eric Noulard eric.noulard at gmail.com
Mon Aug 10 12:11:40 EDT 2009


2009/8/10 Marcel Loose <loose at astron.nl>:
> Hi all,
>
> Is there a way to catch the CMake Error 'get_directory_property' when
> requesting a property from a directory that has not yet been processed
> by CMake.

The doc says:
"If the property is not found, CMake will report an error."
and
"You can only get properties of a directory during
       or after it has been traversed by cmake."


> I need to do this, because, in my situation, it is not an error if one
> or more directories are not present (i.e. checked out). I would like
> get_directory_property() to return FALSE or NOTFOUND when it cannot find
> the requested directory, so that I can take appropriate action myself.
> Is that somehow possible?

May be you can check the directory exists with

if(EXISTS <directory>)

before

calling get_directory_property.

or coding your own

my_get_directory_property which does the job you want.

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list