forked from rpavlik/cmake-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindPerlModules.cmake
78 lines (74 loc) · 2.21 KB
/
FindPerlModules.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
# - try to find perl modules, passed as COMPONENTS
#
# Non-cache variable you might use in your CMakeLists.txt:
# PERLMODULES_FOUND
#
# Requires these CMake modules:
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
#
# Original Author:
# 2012 Ryan Pavlik <[email protected]> <[email protected]>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2012.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
if(NOT PERL_FOUND)
find_package(Perl QUIET)
endif()
set(_deps_check)
if(PERL_FOUND)
foreach(module ${PerlModules_FIND_COMPONENTS})
string(REPLACE "::" "/" modfilename "${module}.pm")
string(REPLACE "::" "_" modvarname "PERLMODULES_${module}_MODULE")
string(TOUPPER "${modvarname}" modvarname)
list(APPEND _deps_check ${modvarname})
if(NOT ${modvarname})
if(NOT PerlModules_FIND_QUIETLY)
message(STATUS "Checking for perl module ${module}")
endif()
execute_process(COMMAND
"${PERL_EXECUTABLE}"
"-e"
"use ${module}; print \$INC{\"${modfilename}\"}"
RESULT_VARIABLE result_code
OUTPUT_VARIABLE filename
ERROR_VARIABLE error_info
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(result_code EQUAL 0)
if(NOT PerlModules_FIND_QUIETLY)
message(STATUS
"Checking for perl module ${module} - found at ${filename}")
endif()
set(${modvarname}
"${filename}"
CACHE
FILEPATH
"Location found for module ${module}"
FORCE)
mark_as_advanced(${modvarname})
else()
if(NOT PerlModules_FIND_QUIETLY)
message(STATUS "Checking for perl module ${module} - failed")
endif()
set(${modvarname}
"NOTFOUND"
CACHE
FILEPATH
"No location found for module ${module}"
FORCE)
file(APPEND
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the Perl module ${module} exists failed with the following error output:\n"
"${error_info}\n\n")
endif()
endif()
endforeach()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PerlModules
DEFAULT_MSG
PERL_FOUND
${_deps_check})