Debian Codegraph @

mesonbuild/cmake/data/preload.cmake

raw
1 if(MESON_PS_LOADED)
2 return()
3 endif()
4
5 set(MESON_PS_LOADED ON)
6
7 cmake_policy(PUSH)
8 cmake_policy(SET CMP0054 NEW) # https://cmake.org/cmake/help/latest/policy/CMP0054.html
9
10 # Dummy macros that have a special meaning in the meson code
11 macro(meson_ps_execute_delayed_calls)
12 endmacro()
13
14 macro(meson_ps_reload_vars)
15 endmacro()
16
17 macro(meson_ps_disabled_function)
18 message(WARNING "The function '${ARGV0}' is disabled in the context of CMake subprojects.\n"
19 "This should not be an issue but may lead to compilation errors.")
20 endmacro()
21
22 # Helper macro to inspect the current CMake state
23 macro(meson_ps_inspect_vars)
24 set(MESON_PS_CMAKE_CURRENT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
25 set(MESON_PS_CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
26 meson_ps_execute_delayed_calls()
27 endmacro()
28
29
30 # Override some system functions with custom code and forward the args
31 # to the original function
32 macro(add_custom_command)
33 meson_ps_inspect_vars()
34 _add_custom_command(${ARGV})
35 endmacro()
36
37 macro(add_custom_target)
38 meson_ps_inspect_vars()
39 _add_custom_target(${ARGV})
40 endmacro()
41
42 macro(set_property)
43 meson_ps_inspect_vars()
44 _set_property(${ARGV})
45 endmacro()
46
47 function(set_source_files_properties)
48 set(FILES)
49 set(I 0)
50 set(PROPERTIES OFF)
51
52 while(I LESS ARGC)
53 if(NOT PROPERTIES)
54 if("${ARGV${I}}" STREQUAL "PROPERTIES")
55 set(PROPERTIES ON)
56 else()
57 list(APPEND FILES "${ARGV${I}}")
58 endif()
59
60 math(EXPR I "${I} + 1")
61 else()
62 set(ID_IDX ${I})
63 math(EXPR PROP_IDX "${ID_IDX} + 1")
64
65 set(ID "${ARGV${ID_IDX}}")
66 set(PROP "${ARGV${PROP_IDX}}")
67
68 set_property(SOURCE ${FILES} PROPERTY "${ID}" "${PROP}")
69 math(EXPR I "${I} + 2")
70 endif()
71 endwhile()
72 endfunction()
73
74 # Disable some functions that would mess up the CMake meson integration
75 macro(target_precompile_headers)
76 meson_ps_disabled_function(target_precompile_headers)
77 endmacro()
78
79 set(MESON_PS_DELAYED_CALLS add_custom_command;add_custom_target;set_property)
80 meson_ps_reload_vars()
81
82 cmake_policy(POP)