File: BubblewrapSandboxChecks.cmake

package info (click to toggle)
webkit2gtk 2.42.2-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 362,452 kB
  • sloc: cpp: 2,881,971; javascript: 282,447; ansic: 134,088; python: 43,789; ruby: 18,308; perl: 15,872; asm: 14,389; xml: 4,395; yacc: 2,350; sh: 2,074; java: 1,734; lex: 1,323; makefile: 288; pascal: 60
file content (58 lines) | stat: -rw-r--r-- 2,863 bytes parent folder | download | duplicates (10)
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
if (ENABLE_BUBBLEWRAP_SANDBOX)
    find_package(Libseccomp)
    if (NOT Libseccomp_FOUND)
        message(FATAL_ERROR "libseccomp is needed for ENABLE_BUBBLEWRAP_SANDBOX")
    endif ()

    if (NOT DEFINED BWRAP_EXECUTABLE)
        if (CMAKE_CROSSCOMPILING)
            message(FATAL_ERROR "bwrap executable version 0.3.1 or newer is needed for ENABLE_BUBBLEWRAP_SANDBOX. Unable to autodetect the path when cross-compiling. "
                                "Please define define the CMake variable BWRAP_EXECUTABLE with the run-time full-path to the 'bwrap' program.")
        else ()
            find_program(BWRAP_EXECUTABLE bwrap)
            if (NOT BWRAP_EXECUTABLE)
                message(FATAL_ERROR "bwrap executable is needed for ENABLE_BUBBLEWRAP_SANDBOX. "
                       "Either install it or use the CMake variable BWRAP_EXECUTABLE to define the runtime path.")
            endif ()
        endif ()
    endif ()

    if (NOT DEFINED DBUS_PROXY_EXECUTABLE)
        if (CMAKE_CROSSCOMPILING)
            message(FATAL_ERROR "xdg-dbus-proxy executable is needed for ENABLE_BUBBLEWRAP_SANDBOX.  Unable to autodetect the path when cross-compiling. "
                                "Please define define the CMake variable DBUS_PROXY_EXECUTABLE with the run-time full-path to the 'xdg-dbus-proxy' program.")
        else ()
            find_program(DBUS_PROXY_EXECUTABLE xdg-dbus-proxy)
            if (NOT DBUS_PROXY_EXECUTABLE)
                message(FATAL_ERROR "xdg-dbus-proxy executable not found and is needed for ENABLE_BUBBLEWRAP_SANDBOX. "
                       "Either install it or use the CMake variable DBUS_PROXY_EXECUTABLE to define the runtime path.")
            endif ()
        endif ()
    endif ()

    # Do some extra sanity checks
    if (NOT IS_ABSOLUTE "${BWRAP_EXECUTABLE}")
        message(FATAL_ERROR "The value for BWRAP_EXECUTABLE should be a full path.")
    endif ()
    if (NOT IS_ABSOLUTE "${DBUS_PROXY_EXECUTABLE}")
        message(FATAL_ERROR "The value for DBUS_PROXY_EXECUTABLE should be a full path.")
    endif ()
    # This version check can only be done when not cross-compiling
    if (NOT CMAKE_CROSSCOMPILING)
        execute_process(
            COMMAND "${BWRAP_EXECUTABLE}" --version
            RESULT_VARIABLE BWRAP_RET
            OUTPUT_VARIABLE BWRAP_OUTPUT
        )
        if (BWRAP_RET)
            message(FATAL_ERROR "Failed to run ${BWRAP_EXECUTABLE}")
        endif ()
        string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" BWRAP_VERSION "${BWRAP_OUTPUT}")
        if (NOT "${BWRAP_VERSION}" VERSION_GREATER_EQUAL "0.3.1")
            message(FATAL_ERROR "bwrap must be >= 0.3.1 but ${BWRAP_VERSION} found")
        endif ()
    endif ()

    add_definitions(-DBWRAP_EXECUTABLE="${BWRAP_EXECUTABLE}")
    add_definitions(-DDBUS_PROXY_EXECUTABLE="${DBUS_PROXY_EXECUTABLE}")
endif ()