File: FindPerlModules.cmake

package info (click to toggle)
kdoctools 5.116.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,924 kB
  • sloc: xml: 5,732; cpp: 901; makefile: 3; sh: 1
file content (67 lines) | stat: -rw-r--r-- 1,837 bytes parent folder | download | duplicates (5)
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
63
64
65
66
67
#.rst:
# FindPerlModules
# ---------------
#
# Check that Perl has certain modules available.
#
# If PERL_EXECUTABLE is set, uses that, otherwise calls the Perl find module.
#
# To use, pass the perl module names (in the form you would use in a Perl
# ``use`` statement) as components.
#
# This will define the following variables:
#
# ``Perl_<module>_FOUND``
#     True if the given Perl module could be loaded by Perl
#
# where ``<module>`` is either the name passed as a component, or a version
# with ``::`` replaced by ``_``.

# SPDX-FileCopyrightText: 2015 Alex Merry <alex.merry@kde.org>
#
# SPDX-License-Identifier: BSD-3-Clause

if (NOT PERL_EXECUTABLE)
    find_package(Perl)
endif()

include(FindPackageHandleStandardArgs)

if (PERL_EXECUTABLE)
    set(PerlModules_all_modules_found TRUE)
    foreach(_comp ${PerlModules_FIND_COMPONENTS})
        execute_process(
            COMMAND ${PERL_EXECUTABLE} -e "use ${_comp}"
            RESULT_VARIABLE _result
            OUTPUT_QUIET
            ERROR_QUIET
        )
        string(REPLACE "::" "_" _comp_sanitised "${_comp}")
        if (_result EQUAL 0)
            set(PerlModules_${_comp_sanitised}_FOUND TRUE)
        else()
            set(PerlModules_${_comp_sanitised}_FOUND FALSE)
            set(PerlModules_all_modules_found FALSE)
        endif()
        find_package_handle_standard_args(PerlModules_${_comp}
            FOUND_VAR
                PerlModules_${_comp}_FOUND
            REQUIRED_VARS
                PerlModules_${_comp_sanitised}_FOUND
            )
    endforeach()
endif()

find_package_handle_standard_args(PerlModules
    FOUND_VAR
        PerlModules_FOUND
    REQUIRED_VARS
        PerlModules_all_modules_found
    HANDLE_COMPONENTS
)

include(FeatureSummary)
set_package_properties(PerlModules PROPERTIES
    URL "https://www.cpan.org"
)