2016-09-27 19:01:08 +00:00
|
|
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
|
|
|
|
2018-10-22 14:31:08 +00:00
|
|
|
#[=======================================================================[.rst:
|
|
|
|
FindPerl
|
|
|
|
--------
|
|
|
|
|
|
|
|
Find perl
|
|
|
|
|
|
|
|
this module looks for Perl
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
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-23 20:55:34 +00:00
|
|
|
|
2012-11-03 20:35:44 +00:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake)
|
2001-11-02 21:44:00 +00:00
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
set(PERL_POSSIBLE_BIN_PATHS
|
2001-12-04 15:55:17 +00:00
|
|
|
${CYGWIN_INSTALL_PATH}/bin
|
2004-08-27 02:52:53 +00:00
|
|
|
)
|
2001-11-02 21:44:00 +00:00
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
if(WIN32)
|
|
|
|
get_filename_component(
|
2012-08-13 17:42:58 +00:00
|
|
|
ActivePerl_CurrentVersion
|
|
|
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActivePerl;CurrentVersion]"
|
2008-01-25 18:07:59 +00:00
|
|
|
NAME)
|
2012-08-13 17:47:32 +00:00
|
|
|
set(PERL_POSSIBLE_BIN_PATHS ${PERL_POSSIBLE_BIN_PATHS}
|
2012-08-13 17:42:58 +00:00
|
|
|
"C:/Perl/bin"
|
2018-05-24 13:40:45 +00:00
|
|
|
"C:/Strawberry/perl/bin"
|
2008-01-25 18:07:59 +00:00
|
|
|
[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActivePerl\\${ActivePerl_CurrentVersion}]/bin
|
|
|
|
)
|
2012-08-13 17:50:14 +00:00
|
|
|
endif()
|
2008-01-25 18:07:59 +00:00
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
find_program(PERL_EXECUTABLE
|
2008-01-25 18:07:59 +00:00
|
|
|
NAMES perl
|
|
|
|
PATHS ${PERL_POSSIBLE_BIN_PATHS}
|
|
|
|
)
|
2002-09-03 12:33:56 +00:00
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
if(PERL_EXECUTABLE)
|
2012-01-18 17:08:43 +00:00
|
|
|
### PERL_VERSION
|
2012-08-13 17:47:32 +00:00
|
|
|
execute_process(
|
2012-01-18 17:08:43 +00: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 17:47:32 +00: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 17:08:43 +00: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 17:47:32 +00:00
|
|
|
if(NOT PERL_VERSION_RESULT_VARIABLE AND PERL_VERSION_OUTPUT_VARIABLE MATCHES "This is perl.*[ \\(]v([0-9\\._]+)[ \\)]")
|
2014-04-06 19:30:00 +00:00
|
|
|
set(PERL_VERSION_STRING "${CMAKE_MATCH_1}")
|
2012-08-13 17:47:32 +00:00
|
|
|
elseif(NOT PERL_VERSION_RESULT_VARIABLE AND PERL_VERSION_OUTPUT_VARIABLE MATCHES "This is perl, version ([0-9\\._]+) +")
|
2014-04-06 19:30:00 +00:00
|
|
|
set(PERL_VERSION_STRING "${CMAKE_MATCH_1}")
|
2012-08-13 17:47:32 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2012-08-13 17:50:14 +00:00
|
|
|
endif()
|
2012-01-18 17:08:43 +00:00
|
|
|
|
2007-07-19 13:00:51 +00:00
|
|
|
# Deprecated settings for compatibility with CMake1.4
|
2012-08-13 17:47:32 +00:00
|
|
|
set(PERL ${PERL_EXECUTABLE})
|
2002-09-03 12:33:56 +00:00
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
2012-01-18 17:08:43 +00:00
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Perl
|
|
|
|
REQUIRED_VARS PERL_EXECUTABLE
|
|
|
|
VERSION_VAR PERL_VERSION_STRING)
|
2006-10-24 21:56:59 +00:00
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
mark_as_advanced(PERL_EXECUTABLE)
|