[CMake] Bug? project(X T) returns weird error
Eric Noulard
eric.noulard at gmail.com
Thu Jul 22 04:28:25 EDT 2010
2010/7/21 Brian Davis <bitminer at gmail.com>:
> I agree with Olaf. CMake needs better error reporting for parameter
> checking on macros and functions
Good idea but this seems difficult to do.
In Olaf case it may be doable to spit out a better error message explicitely
saying that "T" was considered as the "<language>" argument of PROJECT,
because PROJECT is a builtin
however...
> I ran into similar with use of:
>
> http://www.cmake.org/Wiki/CMakeMacroParseArguments
>
> where I elided the empty quotes "" and it was as though the macro/function
> it was contained in did not exist as though it could not find the ending
> paren ")". I realize I should always use functions as specified, but as
> humans inevitably make mistakes it's best to have decent error reporting so
> we can correct our ways.
[...]
In this case the MACRO CMake command has only "positional" arguments handling.
So if you miss-use the ParseArguments macros the better you can do is enhance
the ParseArguments macro in order to do a better job while checking
its arguments.
May be the only way to have a better error reporting would be to have a new
kwmacro(<name> KEYWORD <kw1> arg1 KEYWORD kw2 arg2 .... KEYWORD kwN argN)
kwmacro(<name>)
that would support keyword call instead of positional call.
i.e.
kwmacro(PARSE_ARGUMENTS
KEYWORD PREFIX prefixarg
KEYWORD ARGNAMES argnames
KEYWORD OPTIONSNAME optnames)
kwmacro(PARSE_ARGUMENTS)
then you MUST call
PARSE_ARGUMENTS(hello world
PREFIX ARG
ARGNAMES "LIST1;LIST2;LIST3"
OPTIONSNAME "OPTION1;OPTION2;OPTION3")
i.e. non keyword argument MUST be given before ANY keywords arg
(pretty much like in Python).
kwmacro as a builtin would set for you
KW_<keyword>_GIVEN to TRUE is the <keyword> have been given.
KW_<keyword>_ARGS to the list of arguments given to <keyword>.
KW_DEFAULTS_ARGS will be the list of positional arguments.
basically it is the feature provided by PARSE_ARGUMENTS but as a
more robust builtin.
--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
More information about the CMake
mailing list