File: GetAllCMakeProperties.cmake

package info (click to toggle)
ycm-cmake-modules 0.13.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,640 kB
  • sloc: python: 319; sh: 181; makefile: 22
file content (57 lines) | stat: -rw-r--r-- 1,944 bytes parent folder | download
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
55
56
57
# SPDX-FileCopyrightText: 2012-2021 Istituto Italiano di Tecnologia (IIT)
# SPDX-License-Identifier: BSD-3-Clause

#[=======================================================================[.rst:
GetAllCMakeProperties
---------------------

Return a list containing the names of all known CMake Properties.

Only properties returned by ``cmake --help-property-list`` are returned,
custom properties will not be on the returned list.

Properties containing ``<CONFIG>`` or ``<LANG>`` are expanded to the correct
property name.
#]=======================================================================]

cmake_policy(PUSH)
if(POLICY CMP0054)
  cmake_policy(SET CMP0054 NEW)
endif()

function(GET_ALL_CMAKE_PROPERTIES _var)

  execute_process(COMMAND ${CMAKE_COMMAND} --help-property-list
                  OUTPUT_VARIABLE ${_var}
                  OUTPUT_STRIP_TRAILING_WHITESPACE)

  string(REGEX REPLACE "[\r\n]+" ";" ${_var} "${${_var}}")
  list(REMOVE_DUPLICATES ${_var})

  foreach(_prop_name ${${_var}})
    if("${_prop_name}" MATCHES "LOCATION")
      # Remove *LOCATION* properties (see CMP0026)
      list(REMOVE_ITEM _all_properties "${_prop_name}")
    elseif("${_prop_name}" MATCHES "<CONFIG>")
      # Replace all possible configurations
      list(REMOVE_ITEM ${_var} "${_prop_name}")
      foreach(_config Release Debug)
        string(TOUPPER "${_config}" _config)
        string(REPLACE "<CONFIG>" "${_config}" _prop_name_config "${_prop_name}")
        list(APPEND ${_var} ${_prop_name_config})
      endforeach()
    elseif("${_prop_name}" MATCHES "<LANG>")
      # Replace all possible languages
      list(REMOVE_ITEM ${_var} "${_prop_name}")
      foreach(_config C CXX Fortran)
        string(REPLACE "<LANG>" "${_config}" _prop_name_lang "${_prop_name}")
        list(APPEND ${_var} ${_prop_name_lang})
      endforeach()
    endif()
  endforeach()

  set(${_var} ${${_var}} PARENT_SCOPE)

endfunction()

cmake_policy(POP)