-
Notifications
You must be signed in to change notification settings - Fork 16
/
FindPerlLibs.cmake
88 lines (78 loc) · 2.97 KB
/
FindPerlLibs.cmake
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# ============================================================================
# Copyright (c) 2011-2012 University of Pennsylvania
# Copyright (c) 2013-2014 Andreas Schuh
# All rights reserved.
#
# See COPYING file for license information or visit
# http://opensource.andreasschuh.com/cmake-basis/download.html#license
# ============================================================================
##############################################################################
# @file FindPerlLibs.cmake
# @brief Find Perl libraries. Fixes issue with CMake's default FindPerlLibs.
#
# @sa http://www.cmake.org/pipermail/cmake/2008-July/022638.html
#
# @ingroup CMakeFindModules
##############################################################################
# ----------------------------------------------------------------------------
# use CMake's FindPerlLibs.cmake module
set (CMAKE_MODULE_PATH_BACKUP "${CMAKE_MODULE_PATH}")
set (PerlLIbs_FIND_REQUIRED_BACKUP "${PerlLibs_FIND_REQUIRED}")
set (PerlLIbs_FIND_QUIETLY_BACKUP "${PerlLibs_FIND_QUIETLY}")
set (CMAKE_MODULE_PATH)
set (PerlLibs_FIND_REQUIRED FALSE)
set (PerlLibs_FIND_QUIETLY TRUE)
find_package (PerlLibs)
set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH_BACKUP}")
set (PerlLIbs_FIND_REQUIRED "${PerlLibs_FIND_REQUIRED_BACKUP}")
set (PerlLIbs_FIND_QUIETLY "${PerlLibs_FIND_QUIETLY_BACKUP}")
set (PerlLibs_FIND_REQUIRED_BACKUP)
set (PerlLibs_FIND_QUIETLY_BACKUP)
set (CMAKE_MODULE_PATH_BACKUP)
# ----------------------------------------------------------------------------
# try to fix any issues
if (PERL_EXECUTABLE)
execute_process (
COMMAND "${PERL_EXECUTABLE}" -MConfig -e "print \$Config{version}"
OUTPUT_VARIABLE PERL_OUTPUT
RESULT_VARIABLE PERL_RETURN_VALUE
)
if (PERL_RETURN_VALUE EQUAL 0)
set (PERL_VERSION ${PERL_OUTPUT})
endif ()
# try to fix failure in PERL_INCLUDE_PATH
if (PERL_INCLUDE_PATH MATCHES ".*-NOTFOUND")
execute_process (
COMMAND "${PERL_EXECUTABLE}" -MConfig -e "print \$Config{archlibexp}"
OUTPUT_VARIABLE PERL_OUTPUT
RESULT_VARIABLE PERL_RETURN_VALUE
)
if (NOT PERL_RETURN_VALUE)
find_path (PERL_INCLUDE_PATH perl.h "${PERL_OUTPUT}/CORE")
endif ()
endif ()
# try to fix failure in PERL_LIBRARY
IF (PERL_LIBRARY MATCHES ".*-NOTFOUND")
execute_process (
COMMAND "${PERL_EXECUTABLE}" -MConfig -e "print \$Config{libperl}"
OUTPUT_VARIABLE PERL_OUTPUT
RESULT_VARIABLE PERL_RETURN_VALUE
)
if (NOT PERL_RETURN_VALUE)
find_library (PERL_LIBRARY NAMES "${PERL_OUTPUT}" PATHS "${PERL_INCLUDE_PATH}")
endif ()
endif ()
endif ()
# ----------------------------------------------------------------------------
# handle the QUIETLY and REQUIRED arguments and set *_FOUND to TRUE
# if all listed variables are found or TRUE
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (
PerlLibs
REQUIRED_VARS
PERL_LIBRARY
PERL_INCLUDE_PATH
VERSION_VAR
PERL_VERSION
)
set (PerlLibs_FOUND "${PERLLIBS_FOUND}")