aboutsummaryrefslogtreecommitdiff
path: root/find-modules/Find7z.cmake
blob: eaa544d57a0c15c8f82b08ca826fb3019d310084 (plain)
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
# SPDX-FileCopyrightText: 2019, 2021 Friedrich W. H. Kossebau <kossebau@kde.org>
#
# SPDX-License-Identifier: BSD-3-Clause

#[=======================================================================[.rst:
Find7z
------

Try to find 7z.

If the 7z executable is not in your PATH, you can provide
an alternative name or full path location with the ``7z_EXECUTABLE``
variable.

This will define the following variables:

``7z_FOUND``
    TRUE if 7z is available

``7z_EXECUTABLE``
    Path to 7z executable

If ``7z_FOUND`` is TRUE, it will also define the following imported
target:

``7z::7z``
    Path to 7z executable

Since 5.85.0.
#]=======================================================================]

find_program(7z_EXECUTABLE NAMES 7z.exe 7za.exe)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(7z
    FOUND_VAR
        7z_FOUND
    REQUIRED_VARS
        7z_EXECUTABLE
)
mark_as_advanced(7z_EXECUTABLE)

if(NOT TARGET 7z::7z AND 7z_FOUND)
    add_executable(7z::7z IMPORTED)
    set_target_properties(7z::7z PROPERTIES
        IMPORTED_LOCATION "${7z_EXECUTABLE}"
    )
endif()

include(FeatureSummary)
set_package_properties(7z PROPERTIES
    URL "https://www.7-zip.org/"
    DESCRIPTION "Data (de)compression program"
)