File: CMakeHelpers.cmake

package info (click to toggle)
kodi 2%3A20.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 143,820 kB
  • sloc: cpp: 664,925; xml: 68,398; ansic: 37,223; python: 6,903; sh: 4,209; javascript: 2,325; makefile: 1,754; perl: 969; java: 513; cs: 390; objc: 340
file content (54 lines) | stat: -rw-r--r-- 1,924 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# This file contains functions that support the debugging of the CMake files.

# This file shouldn't be included per default in any CMake file. It should be
# included and used only on demand. All functions are prefixed with "debug_".
#
# Usage:
# include(scripts/common/CMakeHelpers.cmake)
# debug_print_variables()

# Print all CMake variables.
macro(debug_print_variables)
  get_cmake_property(_variableNames VARIABLES)
  foreach(_variableName ${_variableNames})
    message(STATUS "${_variableName} = ${${_variableName}}")
  endforeach()
endmacro()

# Get all properties that CMake supports and convert them to a list.
function(debug_get_properties VAR)
  execute_process(COMMAND cmake --help-property-list
                  OUTPUT_VARIABLE _properties)
  string(REGEX REPLACE ";" "\\\\;" _properties "${_properties}")
  string(REGEX REPLACE "\n" ";" _properties "${_properties}")
  list(REMOVE_DUPLICATES _properties)
  list(REMOVE_ITEM _properties LOCATION)
  set(${VAR} ${_properties} PARENT_SCOPE)
endfunction()

# List all properties.
function(debug_list_properties)
  debug_get_properties(_properties)
  message("CMake properties = ${_properties}")
endfunction()

# Print all set properties of a specified target.
function(debug_print_target_properties target)
  if(NOT TARGET ${target})
    message(FATAL_ERROR "There is no target named '${target}'")
  endif()

  debug_get_properties(_properties)

  # Reading LOCATION property is deprecated and triggers a fatal error.
  string(REGEX REPLACE ";LOCATION;|LOCATION" "" _properties "${_properties}")
  string(REGEX REPLACE "<CONFIG>" "${CMAKE_BUILD_TYPE}" _properties
         "${_properties}")
  foreach(_property ${_properties})
    get_property(_value TARGET ${target} PROPERTY ${_property} SET)
    if(_value)
      get_target_property(_value ${target} ${_property})
      message("${target} ${_property} = ${_value}")
    endif()
  endforeach()
endfunction()