2016-09-27 22:01:08 +03:00
|
|
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
|
|
|
|
2013-10-15 19:17:36 +04:00
|
|
|
#.rst:
|
|
|
|
# FindPerl
|
|
|
|
# --------
|
|
|
|
#
|
|
|
|
# Find perl
|
|
|
|
#
|
2001-10-24 00:55:34 +04:00
|
|
|
# this module looks for Perl
|
|
|
|
#
|
2013-10-15 19:17:36 +04:00
|
|
|
# ::
|
|
|
|
#
|
|
|
|
# PERL_EXECUTABLE - the full path to perl
|
|
|
|
# PERL_FOUND - If false, don't attempt to use perl.
|
|
|
|
# PERL_VERSION_STRING - version of perl found (since CMake 2.8.8)
|
2001-10-24 00:55:34 +04:00
|
|
|
|
2012-11-04 00:35:44 +04:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake)
|
2001-11-03 00:44:00 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(PERL_POSSIBLE_BIN_PATHS
|
2001-12-04 18:55:17 +03:00
|
|
|
${CYGWIN_INSTALL_PATH}/bin
|
2004-08-27 06:52:53 +04:00
|
|
|
)
|
2001-11-03 00:44:00 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(WIN32)
|
|
|
|
get_filename_component(
|
2012-08-13 21:42:58 +04:00
|
|
|
ActivePerl_CurrentVersion
|
|
|
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActivePerl;CurrentVersion]"
|
2008-01-25 21:07:59 +03:00
|
|
|
NAME)
|
2012-08-13 21:47:32 +04:00
|
|
|
set(PERL_POSSIBLE_BIN_PATHS ${PERL_POSSIBLE_BIN_PATHS}
|
2012-08-13 21:42:58 +04:00
|
|
|
"C:/Perl/bin"
|
2008-01-25 21:07:59 +03:00
|
|
|
[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActivePerl\\${ActivePerl_CurrentVersion}]/bin
|
|
|
|
)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2008-01-25 21:07:59 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
find_program(PERL_EXECUTABLE
|
2008-01-25 21:07:59 +03:00
|
|
|
NAMES perl
|
|
|
|
PATHS ${PERL_POSSIBLE_BIN_PATHS}
|
|
|
|
)
|
2002-09-03 16:33:56 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(PERL_EXECUTABLE)
|
2012-01-18 21:08:43 +04:00
|
|
|
### PERL_VERSION
|
2012-08-13 21:47:32 +04:00
|
|
|
execute_process(
|
2012-01-18 21:08:43 +04:00
|
|
|
COMMAND
|
|
|
|
${PERL_EXECUTABLE} -V:version
|
|
|
|
OUTPUT_VARIABLE
|
|
|
|
PERL_VERSION_OUTPUT_VARIABLE
|
|
|
|
RESULT_VARIABLE
|
|
|
|
PERL_VERSION_RESULT_VARIABLE
|
|
|
|
ERROR_QUIET
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT PERL_VERSION_RESULT_VARIABLE AND NOT PERL_VERSION_OUTPUT_VARIABLE MATCHES "^version='UNKNOWN'")
|
|
|
|
string(REGEX REPLACE "version='([^']+)'.*" "\\1" PERL_VERSION_STRING ${PERL_VERSION_OUTPUT_VARIABLE})
|
|
|
|
else()
|
|
|
|
execute_process(
|
2012-01-18 21:08:43 +04:00
|
|
|
COMMAND ${PERL_EXECUTABLE} -v
|
|
|
|
OUTPUT_VARIABLE PERL_VERSION_OUTPUT_VARIABLE
|
|
|
|
RESULT_VARIABLE PERL_VERSION_RESULT_VARIABLE
|
|
|
|
ERROR_QUIET
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT PERL_VERSION_RESULT_VARIABLE AND PERL_VERSION_OUTPUT_VARIABLE MATCHES "This is perl.*[ \\(]v([0-9\\._]+)[ \\)]")
|
2014-04-06 23:30:00 +04:00
|
|
|
set(PERL_VERSION_STRING "${CMAKE_MATCH_1}")
|
2012-08-13 21:47:32 +04:00
|
|
|
elseif(NOT PERL_VERSION_RESULT_VARIABLE AND PERL_VERSION_OUTPUT_VARIABLE MATCHES "This is perl, version ([0-9\\._]+) +")
|
2014-04-06 23:30:00 +04:00
|
|
|
set(PERL_VERSION_STRING "${CMAKE_MATCH_1}")
|
2012-08-13 21:47:32 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-01-18 21:08:43 +04:00
|
|
|
|
2007-07-19 17:00:51 +04:00
|
|
|
# Deprecated settings for compatibility with CMake1.4
|
2012-08-13 21:47:32 +04:00
|
|
|
set(PERL ${PERL_EXECUTABLE})
|
2002-09-03 16:33:56 +04:00
|
|
|
|
2012-08-13 21:42:58 +04:00
|
|
|
# handle the QUIETLY and REQUIRED arguments and set PERL_FOUND to TRUE if
|
2007-07-19 17:00:51 +04:00
|
|
|
# all listed variables are TRUE
|
2012-08-13 21:47:32 +04:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
2012-01-18 21:08:43 +04:00
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Perl
|
|
|
|
REQUIRED_VARS PERL_EXECUTABLE
|
|
|
|
VERSION_VAR PERL_VERSION_STRING)
|
2006-10-25 01:56:59 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
mark_as_advanced(PERL_EXECUTABLE)
|