1 # This file contains functions that support the debugging of the CMake files.
3 # This file shouldn't be included per default in any CMake file. It should be
4 # included and used only on demand. All functions are prefixed with "debug_".
7 # include(scripts/common/CMakeHelpers.cmake)
8 # debug_print_variables()
10 # Print all CMake variables.
11 macro(debug_print_variables)
12 get_cmake_property(_variableNames VARIABLES)
13 foreach(_variableName ${_variableNames})
14 message(STATUS "${_variableName} = ${${_variableName}}")
18 # Get all properties that CMake supports and convert them to a list.
19 function(debug_get_properties VAR)
20 execute_process(COMMAND cmake --help-property-list
21 OUTPUT_VARIABLE _properties)
22 string(REGEX REPLACE ";" "\\\\;" _properties "${_properties}")
23 string(REGEX REPLACE "\n" ";" _properties "${_properties}")
24 list(REMOVE_DUPLICATES _properties)
25 list(REMOVE_ITEM _properties LOCATION)
26 set(${VAR} ${_properties} PARENT_SCOPE)
29 # List all properties.
30 function(debug_list_properties)
31 debug_get_properties(_properties)
32 message("CMake properties = ${_properties}")
35 # Print all set properties of a specified target.
36 function(debug_print_target_properties target)
37 if(NOT TARGET ${target})
38 message(FATAL_ERROR "There is no target named '${target}'")
41 debug_get_properties(_properties)
43 # Reading LOCATION property is deprecated and triggers a fatal error.
44 string(REGEX REPLACE ";LOCATION;|LOCATION" "" _properties "${_properties}")
45 string(REGEX REPLACE "<CONFIG>" "${CMAKE_BUILD_TYPE}" _properties
47 foreach(_property ${_properties})
48 get_property(_value TARGET ${target} PROPERTY ${_property} SET)
50 get_target_property(_value ${target} ${_property})
51 message("${target} ${_property} = ${_value}")