[Cmake-commits] CMake branch, next, updated. v3.2.0-rc2-766-gd476ca2

Brad King brad.king at kitware.com
Thu Feb 26 15:16:53 EST 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  d476ca2703ac95d271d0f5834714a34e5e5dc243 (commit)
       via  4efef3f775e78bdcb4591dc37aa974bc28e8fd84 (commit)
       via  e3363bfbec592393780f9d769bd32334bcfd5953 (commit)
      from  ee27398822ff58d00ee45899128354b27ddf56af (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d476ca2703ac95d271d0f5834714a34e5e5dc243
commit d476ca2703ac95d271d0f5834714a34e5e5dc243
Merge: ee27398 4efef3f
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Feb 26 15:16:52 2015 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Feb 26 15:16:52 2015 -0500

    Merge topic 'macro-function-docs' into next
    
    4efef3f7 Help: Clarify that ARGV# beyond ARGC will have an undefined behavior (#15380)
    e3363bfb Help: Refine the .rst formatting of macro and function documentation


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4efef3f775e78bdcb4591dc37aa974bc28e8fd84
commit 4efef3f775e78bdcb4591dc37aa974bc28e8fd84
Author:     Daniele E. Domenichelli <daniele.domenichelli at iit.it>
AuthorDate: Fri Feb 6 16:53:44 2015 +0100
Commit:     Daniele E. Domenichelli <daniele.domenichelli at iit.it>
CommitDate: Thu Feb 26 17:42:30 2015 +0100

    Help: Clarify that ARGV# beyond ARGC will have an undefined behavior (#15380)

diff --git a/Help/command/function.rst b/Help/command/function.rst
index 5bbffbf..7ffdfee 100644
--- a/Help/command/function.rst
+++ b/Help/command/function.rst
@@ -24,6 +24,10 @@ This facilitates creating functions with optional arguments.
 Additionally ``ARGV`` holds the list of all arguments given to the
 function and ``ARGN`` holds the list of arguments past the last expected
 argument.
+Referencing to ``ARGV#`` arguments beyond ``ARGC`` have undefined
+behavior. Checking that ``ARGC`` is greater than ``#`` is the only way
+to ensure that ``ARGV#`` was passed to the function as an extra
+argument.
 
 A function opens a new scope: see :command:`set(var PARENT_SCOPE)` for
 details.
diff --git a/Help/command/macro.rst b/Help/command/macro.rst
index 33249c9..6bee69c 100644
--- a/Help/command/macro.rst
+++ b/Help/command/macro.rst
@@ -24,6 +24,10 @@ This facilitates creating macros with optional arguments.
 Additionally ``${ARGV}`` holds the list of all arguments given to the
 macro and ``${ARGN}`` holds the list of arguments past the last expected
 argument.
+Referencing to ``${ARGV#}`` arguments beyond ``${ARGC}`` have undefined
+behavior. Checking that ``${ARGC}`` is greater than ``#`` is the only
+way to ensure that ``${ARGV#}`` was passed to the function as an extra
+argument.
 
 See the :command:`cmake_policy()` command documentation for the behavior
 of policies inside macros.
@@ -37,10 +41,15 @@ replacements much like the C preprocessor would do with a macro.
 Therefore you will NOT be able to use commands like::
 
  if(ARGV1) # ARGV1 is not a variable
+ if(DEFINED ARGV2) # ARGV2 is not a variable
+ if(ARGC GREATER 2) # ARGC is not a variable
  foreach(loop_var IN LISTS ARGN) # ARGN is not a variable
 
-In the first case you can use ``if(${ARGV1})``, in the second case, you can
-use ``foreach(loop_var ${ARGN})`` but this will skip empty arguments.
+In the first case, you can use ``if(${ARGV1})``.
+In the second and third case, the proper way to check if an optional
+variable was passed to the macro is to use ``if(${ARGC} GREATER 2)``.
+In the last case, you can use ``foreach(loop_var ${ARGN})`` but this
+will skip empty arguments.
 If you need to include them, you can use::
 
  set(list_var "${ARGN}")

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e3363bfbec592393780f9d769bd32334bcfd5953
commit e3363bfbec592393780f9d769bd32334bcfd5953
Author:     Daniele E. Domenichelli <daniele.domenichelli at iit.it>
AuthorDate: Thu Feb 26 17:16:42 2015 +0100
Commit:     Daniele E. Domenichelli <daniele.domenichelli at iit.it>
CommitDate: Thu Feb 26 17:19:52 2015 +0100

    Help: Refine the .rst formatting of macro and function documentation

diff --git a/Help/command/function.rst b/Help/command/function.rst
index b18e03c..5bbffbf 100644
--- a/Help/command/function.rst
+++ b/Help/command/function.rst
@@ -1,9 +1,7 @@
 function
 --------
 
-Start recording a function for later invocation as a command.
-
-::
+Start recording a function for later invocation as a command::
 
   function(<name> [arg1 [arg2 [arg3 ...]]])
     COMMAND1(ARGS ...)
@@ -11,21 +9,24 @@ Start recording a function for later invocation as a command.
     ...
   endfunction(<name>)
 
-Define a function named <name> that takes arguments named arg1 arg2
-arg3 (...).  Commands listed after function, but before the matching
-endfunction, are not invoked until the function is invoked.  When it
-is invoked, the commands recorded in the function are first modified
-by replacing formal parameters (${arg1}) with the arguments passed,
-and then invoked as normal commands.  In addition to referencing the
-formal parameters you can reference the variable ARGC which will be
-set to the number of arguments passed into the function as well as
-ARGV0 ARGV1 ARGV2 ...  which will have the actual values of the
-arguments passed in.  This facilitates creating functions with
-optional arguments.  Additionally ARGV holds the list of all arguments
-given to the function and ARGN holds the list of arguments past the
-last expected argument.
+Define a function named ``<name>`` that takes arguments named ``arg1``,
+``arg2``, ``arg3``, (...).
+Commands listed after function, but before the matching
+:command:`endfunction()`, are not invoked until the function is invoked.
+When it is invoked, the commands recorded in the function are first
+modified by replacing formal parameters (``${arg1}``) with the arguments
+passed, and then invoked as normal commands.
+In addition to referencing the formal parameters you can reference the
+``ARGC`` variable which will be set to the number of arguments passed
+into the function as well as ``ARGV0``, ``ARGV1``, ``ARGV2``, ...  which
+will have the actual values of the arguments passed in.
+This facilitates creating functions with optional arguments.
+Additionally ``ARGV`` holds the list of all arguments given to the
+function and ``ARGN`` holds the list of arguments past the last expected
+argument.
 
-A function opens a new scope: see set(var PARENT_SCOPE) for details.
+A function opens a new scope: see :command:`set(var PARENT_SCOPE)` for
+details.
 
-See the cmake_policy() command documentation for the behavior of
-policies inside functions.
+See the :command:`cmake_policy()` command documentation for the behavior
+of policies inside functions.
diff --git a/Help/command/macro.rst b/Help/command/macro.rst
index 258dc50..33249c9 100644
--- a/Help/command/macro.rst
+++ b/Help/command/macro.rst
@@ -1,9 +1,7 @@
 macro
 -----
 
-Start recording a macro for later invocation as a command.
-
-::
+Start recording a macro for later invocation as a command::
 
   macro(<name> [arg1 [arg2 [arg3 ...]]])
     COMMAND1(ARGS ...)
@@ -11,22 +9,24 @@ Start recording a macro for later invocation as a command.
     ...
   endmacro(<name>)
 
-Define a macro named <name> that takes arguments named arg1 arg2 arg3
-(...).  Commands listed after macro, but before the matching endmacro,
-are not invoked until the macro is invoked.  When it is invoked, the
-commands recorded in the macro are first modified by replacing formal
-parameters (``${arg1}``) with the arguments passed, and then invoked as
-normal commands.  In addition to referencing the formal parameters you
-can reference the values ``${ARGC}`` which will be set to the number of
-arguments passed into the function as well as ``${ARGV0}`` ``${ARGV1}``
-``${ARGV2}`` ...  which will have the actual values of the arguments
-passed in.  This facilitates creating macros with optional arguments.
+Define a macro named ``<name>`` that takes arguments named ``arg1``,
+``arg2``, ``arg3``, (...).
+Commands listed after macro, but before the matching
+:command:`endmacro()`, are not invoked until the macro is invoked.
+When it is invoked, the commands recorded in the macro are first
+modified by replacing formal parameters (``${arg1}``) with the arguments
+passed, and then invoked as normal commands.
+In addition to referencing the formal parameters you can reference the
+values ``${ARGC}`` which will be set to the number of arguments passed
+into the function as well as ``${ARGV0}``, ``${ARGV1}``, ``${ARGV2}``,
+...  which will have the actual values of the arguments passed in.
+This facilitates creating macros with optional arguments.
 Additionally ``${ARGV}`` holds the list of all arguments given to the
 macro and ``${ARGN}`` holds the list of arguments past the last expected
 argument.
 
-See the cmake_policy() command documentation for the behavior of
-policies inside macros.
+See the :command:`cmake_policy()` command documentation for the behavior
+of policies inside macros.
 
 Macro Argument Caveats
 ^^^^^^^^^^^^^^^^^^^^^^

-----------------------------------------------------------------------

Summary of changes:
 Help/command/function.rst |   43 ++++++++++++++++++++++++-------------------
 Help/command/macro.rst    |   43 ++++++++++++++++++++++++++-----------------
 2 files changed, 50 insertions(+), 36 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list