File: QtGnTargetHelpers.cmake

package info (click to toggle)
qt6-webengine 6.9.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 4,111,516 kB
  • sloc: cpp: 21,436,007; ansic: 8,086,803; javascript: 2,747,888; python: 856,612; asm: 848,149; xml: 616,344; java: 222,847; sh: 105,206; objc: 99,183; perl: 70,870; cs: 51,103; sql: 40,087; makefile: 26,374; pascal: 25,140; fortran: 24,137; tcl: 9,609; yacc: 8,132; php: 7,051; lisp: 3,462; lex: 1,327; ruby: 914; awk: 339; csh: 120; sed: 36
file content (62 lines) | stat: -rw-r--r-- 2,093 bytes parent folder | download | duplicates (3)
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
58
59
60
61
62
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause

# These are helper functions aim to create and handle properties on gn target

function(add_gn_target target config arch)
    add_custom_target(${target})
    list(REMOVE_ITEM ARGN ${target})
    list(REMOVE_ITEM ARGN ${config})
    list(REMOVE_ITEM ARGN ${arch})
    set_target_properties(${target} PROPERTIES
        ELEMENTS "${ARGN}"
        PREFIX "GN"
        CONFIG ${config}
        ARCH ${arch}
    )
endfunction()

function(extend_gn_target target)
    get_target_property(elements ${target} ELEMENTS)
    cmake_parse_arguments(PARSE_ARGV 1 GN "" "" "CONDITION;${elements}")
    _qt_internal_validate_all_args_are_parsed(GN)

    if("x${GN_CONDITION}" STREQUAL "x")
        set(GN_CONDITION ON)
    endif()
    qt_evaluate_config_expression(result ${GN_CONDITION})
    if(${result})
        message(DEBUG "extend_gn_target(${target} CONDITION ${GN_CONDITION} ...): Evaluated")
        set_properties_on_target_scope(${target})
    endif()
endfunction()

macro(set_properties_on_target_scope target)
    get_target_property(element_list ${target} ELEMENTS)
    get_target_property(prefix ${target} PREFIX)
    foreach(element IN LISTS element_list)
        if(${prefix}_${element})
            set_property(TARGET ${target} APPEND PROPERTY ${prefix}_${element} ${${prefix}_${element}})
        endif()
    endforeach()
endmacro()

function(extend_gn_list out_list)
    cmake_parse_arguments(PARSE_ARGV 1 GN "" "" "ARGS;CONDITION")
    _qt_internal_validate_all_args_are_parsed(GN)

    if("x${GN_CONDITION}" STREQUAL "x")
        set(GN_CONDITION ON)
    endif()
    qt_evaluate_config_expression(result ${GN_CONDITION})
    if(${result})
        set(value "true")
    else()
        set(value "false")
    endif()
    message(DEBUG "extend_gn_list(${out_list} ${GN_ARGS} CONDITION ${GN_CONDITION} ...): Evaluated to ${value}")
    foreach(gnArg ${GN_ARGS})
        set(${out_list} "${${out_list}}" "${gnArg}=${value}")
    endforeach()
    set(${out_list} "${${out_list}}" PARENT_SCOPE)
endfunction()