-
Notifications
You must be signed in to change notification settings - Fork 10
/
FindPerlLibs.cmake
99 lines (87 loc) · 3.44 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
89
90
91
92
93
94
95
96
97
98
99
# - Find Perl libraries
# This module finds if PERL is installed and determines where the include files
# and libraries are. It also determines what the name of the library is. This
# code sets the following variables:
#
# PERL_INCLUDE_PATH = path to where perl.h is found
# PERL_EXECUTABLE = full path to the perl binary
#
SET(PERL_POSSIBLE_INCLUDE_PATHS
/usr/lib/perl/5.8.3/CORE
/usr/lib/perl/5.8.2/CORE
/usr/lib/perl/5.8.1/CORE
/usr/lib/perl/5.8.0/CORE
/usr/lib/perl/5.8/CORE
)
SET(PERL_POSSIBLE_LIB_PATHS
/usr/lib
/opt/local/lib
)
FIND_PATH(PERL_INCLUDE_PATH perl.h
${PERL_POSSIBLE_INCLUDE_PATHS})
FIND_PROGRAM(PERL_EXECUTABLE /usr/bin/perl )
IF(PERL_EXECUTABLE)
EXEC_PROGRAM(${PERL_EXECUTABLE}
ARGS -e "'use Config; print \$Config{libperl}, \"\\n\"'"
OUTPUT_VARIABLE PERL_LIBRARY_OUTPUT_VARIABLE
RETURN_VALUE PERL_LIBRARY_RETURN_VALUE
)
IF(NOT PERL_LIBRARY_RETURN_VALUE)
FOREACH(path ${PERL_POSSIBLE_LIB_PATHS})
SET(PERL_POSSIBLE_LIBRARY_NAME ${PERL_POSSIBLE_LIBRARY_NAME} "${path}/${PERL_LIBRARY_OUTPUT_VARIABLE}")
ENDFOREACH(path ${PERL_POSSIBLE_LIB_PATHS})
ENDIF(NOT PERL_LIBRARY_RETURN_VALUE)
EXEC_PROGRAM(${PERL_EXECUTABLE}
ARGS -e "'use Config; print \$Config{cppflags}, \"\\n\"'"
OUTPUT_VARIABLE PERL_CPPFLAGS_OUTPUT_VARIABLE
RETURN_VALUE PERL_CPPFLAGS_RETURN_VALUE
)
IF(NOT PERL_CPPFLAGS_RETURN_VALUE)
SET(PERL_EXTRA_C_FLAGS ${PERL_CPPFLAGS_OUTPUT_VARIABLE})
ENDIF(NOT PERL_CPPFLAGS_RETURN_VALUE)
ENDIF(PERL_EXECUTABLE)
FIND_LIBRARY(PERL_LIBRARY
NAMES ${PERL_POSSIBLE_LIBRARY_NAME} perl5.8.0
PATHS ${PERL_POSSIBLE_LIB_PATHS}
)
# handle the QUIETLY and REQUIRED arguments and set PERLLIBS_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PerlLibs DEFAULT_MSG PERL_INCLUDE_PATH)
MARK_AS_ADVANCED(
PERL_INCLUDE_PATH
PERL_EXECUTABLE
PERL_LIBRARY
)
EXECUTE_PROCESS ( COMMAND ${PERL_EXECUTABLE}
-MConfig -e "print \$Config{version}"
OUTPUT_VARIABLE PERL_OUTPUT
RESULT_VARIABLE PERL_RETURN_VALUE )
IF ( NOT PERL_RETURN_VALUE )
SET ( PERL_VERSION ${PERL_OUTPUT} )
ENDIF ( NOT PERL_RETURN_VALUE )
## 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 ( NOT PERL_RETURN_VALUE )
ENDIF ( PERL_INCLUDE_PATH MATCHES .*-NOTFOUND )
## 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 ( NOT PERL_RETURN_VALUE )
ENDIF ( PERL_LIBRARY MATCHES .*-NOTFOUND )
MESSAGE ( STATUS " PERL_VERSION: " ${PERL_VERSION} )
MESSAGE ( STATUS " PERL_EXECUTABLE: " ${PERL_EXECUTABLE} )
MESSAGE ( STATUS " PERL_INCLUDE_PATH: " ${PERL_INCLUDE_PATH} )
MESSAGE ( STATUS " PERL_LIBRARY: " ${PERL_LIBRARY} )