On Friday 08 November 2013, Daniele E. Domenichelli wrote:
> Hello,
> 
> I updated the CMakeParseArguments_EmptyArgs topic, the new behaviour is
> now decided as follows:
> 
> * If CMAKE_MINIMUM_REQUIRED_VERSION < 2.8.13, the default behaviour is
>   to skip empty arguments, otherwise the default behaviour is to keep
>   them.
> * Using the CMAKE_PARSE_ARGUMENTS_DEFAULT_SKIP_EMPTY directory
>   property the user can explicitly set the default behaviour for a
>   folder and its subfolders.
> * Using CMAKE_PARSE_ARGUMENTS_(SKIP|KEEP)_EMPTY or as the first
>   argument of the call after the mandatory ones, the user can specify
>   whether to keep or to skip the empty arguments, regardless of the
>   default behaviour for that cmake_parse_arguments() call.
> 
> Therefore the new syntax is:
> 
>   cmake_parse_arguments(
>     <prefix>
>     <options>
>     <one_value_keywords>
>     <multi_value_keywords>
>     [CMAKE_PARSE_ARGUMENTS_(SKIP|KEEP)_EMPTY]
>     args...
>     )
> 
> Does it look better now?
> 
> 
> Unfortunately there still a big problem, that is probably in the c++
> source code, because "set(<var> "<value>" PARENT_SCOPE)" still fails if
> <value> is empty. This is a small example that shows the problem:
> 
> ---
> 
> function(_foo)
>     set(FOO "" PARENT_SCOPE)
> endfunction()
> 
> foo(FOO "foo")
> _foo()
> if(DEFINED FOO)
>   message("FOO DEFINED")
> else()
>   message("FOO NOT DEFINED")
> endif()
> 
> set(BAR "")
> if(DEFINED BAR)
>   message("BAR DEFINED")
> else()
>   message("BAR NOT DEFINED")
> endif()
> 
> ---
> 
> The output of this is:
> 
> FOO NOT DEFINED
> BAR DEFINED
> 
> So it looks like that "set(FOO "" PARENT_SCOPE)" instead of setting an
> empty FOO value, unsets it in the parent scope, and the behaviour is
> definitely different from set for the current scope.
> 
> This looks like a bug to me... How should I handle this?

the implementation in set() doesn't differentiate whether it was set to empty 
or whether there was no value at all.
In most cases it doesn't matter much whether a variable is empty or not 
defined, if it is dereferenced it gives an empty string in both cases, if() 
also interprets both as false.
It's more or less only if(DEFINED) which detects the difference, right ?

How about adding one new policy "modify handling of empty variables" which is 
used by both ?
Then you don't need the directory property and the extra argument.
Having two separate policies would be cleaner, but it seems a bit overkill to 
me, since most probably both changes won't break many, if any, builds.

Alex
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to