[cmake-developers] Making Config.cmake files safer

Brad King brad.king at kitware.com
Tue Nov 15 14:36:31 EST 2011


On 11/15/2011 1:24 PM, David Cole wrote:
> On Tue, Nov 15, 2011 at 1:19 PM, Alexander Neundorf<neundorf at kde.org>  wrote:
>> function(check_for_file _file _target)
>>   if(NOT EXISTS _file)
>>     message(FATAL_ERROR "... long error message...")
>> endfunction()
>>
>> check_for_file(libFoo123.so  Foo)
>> ...
>> check_for_file(libBar123.so  Bar)
 >>
 > I think the function approach is reasonable...

I don't like the overhead of a function.

>> Or I could collect the files and targets together, but then the error message
>> becomes less straigh forward.

You don't need the error message to do all the files at once.  Just use
a foreach() to test them one at a time.  Die on the first missing one.

-Brad



More information about the cmake-developers mailing list