File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Macros/functions for debugging CMake
2
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3
+ #
4
+ # Copyright (c) 2016, Larry Shaffer, <lshaffer (at) boundlessgeo (dot) com>>
5
+ # Redistribution and use is allowed according to the terms of the BSD license.
6
+ # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
7
+
8
+
9
+ # Dump current CMake variables to file
10
+ #
11
+ # Usage:
12
+ # INCLUDE(CMakeDebugMacros)
13
+ # DUMP_CMAKE_VARS() or DUMP_CMAKE_VARS("regex")
14
+ #
15
+ # regex: optional ARGV0 regular expression for filtering output variable names
16
+ #
17
+ # Outputs the result relative to the current CMake file being processed and
18
+ # writes to a file with name "<file-basename>_cmake-vars.txt" to the current
19
+ # build (binary) directory
20
+ #
21
+ function (DUMP_CMAKE_VARS )
22
+
23
+ get_filename_component (_basename ${CMAKE_CURRENT_LIST_FILE} NAME_WE )
24
+ set (_out "${CMAKE_CURRENT_BINARY_DIR} /${_basename} _cmake-vars.txt" )
25
+
26
+ set (_cmake_vars "" )
27
+ get_cmake_property (_varNames VARIABLES )
28
+ foreach (_varName ${_varNames} )
29
+ if (ARGV0 )
30
+ string (REGEX MATCH "${ARGV0} " _match "${_varName} " )
31
+ if (_match )
32
+ set (_cmake_vars "${_cmake_vars} \n\n ${_varName} =${${_varName} }" )
33
+ endif ()
34
+ else ()
35
+ set (_cmake_vars "${_cmake_vars} \n\n ${_varName} =${${_varName} }" )
36
+ endif ()
37
+ endforeach ()
38
+
39
+ message (STATUS "Dumping current CMake variables to ...\n ${_out} " )
40
+ file (WRITE "${_out} " "${_cmake_vars} " )
41
+
42
+ endfunction (DUMP_CMAKE_VARS )
You can’t perform that action at this time.
0 commit comments