summaryrefslogtreecommitdiffstats
path: root/Help/variable
diff options
context:
space:
mode:
authorAlex Turbov <i.zaufi@gmail.com>2019-12-08 00:26:14 (GMT)
committerAlex Turbov <i.zaufi@gmail.com>2019-12-10 14:43:27 (GMT)
commit90e3e2a7778dc0ec5b421e9657ec49936a3cf174 (patch)
tree6788ff83fc4a9cd7e0e87a2f33f7a3cf0d87d216 /Help/variable
parentdd54290dab61c3342866c71052145271c13468ad (diff)
downloadCMake-90e3e2a7778dc0ec5b421e9657ec49936a3cf174.zip
CMake-90e3e2a7778dc0ec5b421e9657ec49936a3cf174.tar.gz
CMake-90e3e2a7778dc0ec5b421e9657ec49936a3cf174.tar.bz2
cmFunctionCommand: Introduce `CMAKE_CURRENT_FUNCTION*` variables
`CMAKE_CURRENT_FUNCTION` Can be used for diagnostic or debugging messages like the `__PRETTY_FUNCTION__` macro of GCC. `CMAKE_CURRENT_FUNCTION_LIST_DIR` Eliminates the necessity of the additional "global" variables inside a module used to access additional "resource" files from functions defined in the module. ...
Diffstat (limited to 'Help/variable')
-rw-r--r--Help/variable/CMAKE_CURRENT_FUNCTION.rst6
-rw-r--r--Help/variable/CMAKE_CURRENT_FUNCTION_LIST_DIR.rst33
-rw-r--r--Help/variable/CMAKE_CURRENT_FUNCTION_LIST_FILE.rst5
-rw-r--r--Help/variable/CMAKE_CURRENT_FUNCTION_LIST_LINE.rst5
4 files changed, 49 insertions, 0 deletions
diff --git a/Help/variable/CMAKE_CURRENT_FUNCTION.rst b/Help/variable/CMAKE_CURRENT_FUNCTION.rst
new file mode 100644
index 0000000..aa2936c
--- /dev/null
+++ b/Help/variable/CMAKE_CURRENT_FUNCTION.rst
@@ -0,0 +1,6 @@
+CMAKE_CURRENT_FUNCTION
+----------------------
+
+When executing code inside a :command:`function`, this variable
+contains the name of the current function. It can be used for
+diagnostic or debug messages.
diff --git a/Help/variable/CMAKE_CURRENT_FUNCTION_LIST_DIR.rst b/Help/variable/CMAKE_CURRENT_FUNCTION_LIST_DIR.rst
new file mode 100644
index 0000000..0119381
--- /dev/null
+++ b/Help/variable/CMAKE_CURRENT_FUNCTION_LIST_DIR.rst
@@ -0,0 +1,33 @@
+CMAKE_CURRENT_FUNCTION_LIST_DIR
+-------------------------------
+
+When executing code inside a :command:`function`, this variable
+contains the full directory of the listfile defining the current function.
+
+It is quite common practice in CMake that modules use some additional files
+(e.g., templates to render). And the code typically did the following:
+
+.. code-block:: cmake
+ :caption: Bad
+
+ set(_THIS_MODULE_BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
+
+ function(foo)
+ configure_file(
+ "${_THIS_MODULE_BASE_DIR}/some.template.in"
+ some.output
+ )
+ endfunction()
+
+Using this variable inside a function eliminates the neccessity of the
+additional one with "global" scope:
+
+.. code-block:: cmake
+ :caption: Good
+
+ function(foo)
+ configure_file(
+ "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/some.template.in"
+ some.output
+ )
+ endfunction()
diff --git a/Help/variable/CMAKE_CURRENT_FUNCTION_LIST_FILE.rst b/Help/variable/CMAKE_CURRENT_FUNCTION_LIST_FILE.rst
new file mode 100644
index 0000000..d2c846a
--- /dev/null
+++ b/Help/variable/CMAKE_CURRENT_FUNCTION_LIST_FILE.rst
@@ -0,0 +1,5 @@
+CMAKE_CURRENT_FUNCTION_LIST_FILE
+--------------------------------
+
+When executing code inside a :command:`function`, this variable
+contains the full path to the listfile declaring a current function.
diff --git a/Help/variable/CMAKE_CURRENT_FUNCTION_LIST_LINE.rst b/Help/variable/CMAKE_CURRENT_FUNCTION_LIST_LINE.rst
new file mode 100644
index 0000000..5a7cd13
--- /dev/null
+++ b/Help/variable/CMAKE_CURRENT_FUNCTION_LIST_LINE.rst
@@ -0,0 +1,5 @@
+CMAKE_CURRENT_FUNCTION_LIST_LINE
+--------------------------------
+
+When executing code inside a :command:`function`, this variable
+contains the line number in the listfile where a current function has defined.