summaryrefslogtreecommitdiffstats
path: root/cmake/Modules/cmake_variables_helper.cmake
diff options
context:
space:
mode:
authorGravatar Jeremie Guichard <djebrest@gmail.com>2017-02-25 22:27:43 +0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-02-25 09:24:23 -0800
commit7b08f8d23c64b05ec019311347f52bbbd181c4a6 (patch)
treec1513b29bdc2790f6d47fcc684e6bc4284d5a752 /cmake/Modules/cmake_variables_helper.cmake
parentc2997c33c722ab075592ad0c5cb766a52aa7c90c (diff)
downloadsubsurface-7b08f8d23c64b05ec019311347f52bbbd181c4a6.tar.gz
Move CMake variables printing into a utility macro
Added cmake_variables_helper.cmake providing 2 helpers - print_variable - print_all_variables Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
Diffstat (limited to 'cmake/Modules/cmake_variables_helper.cmake')
-rw-r--r--cmake/Modules/cmake_variables_helper.cmake44
1 files changed, 44 insertions, 0 deletions
diff --git a/cmake/Modules/cmake_variables_helper.cmake b/cmake/Modules/cmake_variables_helper.cmake
new file mode 100644
index 000000000..832dd4cc8
--- /dev/null
+++ b/cmake/Modules/cmake_variables_helper.cmake
@@ -0,0 +1,44 @@
+# This file contains helper macro to print env variables as status messages
+
+# print_variable
+#
+# Prints a status message with the value of the variable
+#
+# Parameters:
+# variableName - A string containing the name of the variable to be printed
+#
+# Usage:
+# print_variable(CMAKE_CURRENT_BINARY_DIR)
+#
+# Output:
+# -- CMAKE_CURRENT_BINARY_DIR=/home/xxx/xxx
+#
+macro(print_variable _variableName)
+ message(STATUS "${_variableName}=${${_variableName}}")
+endmacro()
+
+# print_all_variables
+#
+# Prints a status message for all currently defined variables.
+#
+# Parameters:
+# none
+#
+# Usage:
+# print_all_variable()
+#
+# Output:
+# -- ------------------------------ print variables ------------------------------
+# -- CMAKE_CURRENT_BINARY_DIR=/home/xxx/xxx
+# -- ....
+# -- -----------------------------------------------------------------------------
+#
+macro(print_all_variables)
+ message(STATUS "------------------------------ print variables ------------------------------")
+ get_cmake_property(_variableNames VARIABLES)
+
+ foreach(_variableName ${_variableNames})
+ print_variable(${_variableName})
+ endforeach()
+ message(STATUS "-----------------------------------------------------------------------------")
+endmacro()