CMake/Modules/FindPerl.cmake
Brad King 86578eccf2 Simplify CMake per-source license notices
Per-source copyright/license notice headers that spell out copyright holder
names and years are hard to maintain and often out-of-date or plain wrong.
Precise contributor information is already maintained automatically by the
version control tool.  Ultimately it is the receiver of a file who is
responsible for determining its licensing status, and per-source notices are
merely a convenience.  Therefore it is simpler and more accurate for
each source to have a generic notice of the license name and references to
more detailed information on copyright holders and full license terms.

Our `Copyright.txt` file now contains a list of Contributors whose names
appeared source-level copyright notices.  It also references version control
history for more precise information.  Therefore we no longer need to spell
out the list of Contributors in each source file notice.

Replace CMake per-source copyright/license notice headers with a short
description of the license and links to `Copyright.txt` and online information
available from "https://cmake.org/licensing".  The online URL also handles
cases of modules being copied out of our source into other projects, so we
can drop our notices about replacing links with full license text.

Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority
of the replacements mechanically.  Manually fix up shebang lines and trailing
newlines in a few files.  Manually update the notices in a few files that the
script does not handle.
2016-09-27 15:14:44 -04:00

81 lines
2.5 KiB
CMake

# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#.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)
include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake)
set(PERL_POSSIBLE_BIN_PATHS
${CYGWIN_INSTALL_PATH}/bin
)
if(WIN32)
get_filename_component(
ActivePerl_CurrentVersion
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActivePerl;CurrentVersion]"
NAME)
set(PERL_POSSIBLE_BIN_PATHS ${PERL_POSSIBLE_BIN_PATHS}
"C:/Perl/bin"
[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActivePerl\\${ActivePerl_CurrentVersion}]/bin
)
endif()
find_program(PERL_EXECUTABLE
NAMES perl
PATHS ${PERL_POSSIBLE_BIN_PATHS}
)
if(PERL_EXECUTABLE)
### PERL_VERSION
execute_process(
COMMAND
${PERL_EXECUTABLE} -V:version
OUTPUT_VARIABLE
PERL_VERSION_OUTPUT_VARIABLE
RESULT_VARIABLE
PERL_VERSION_RESULT_VARIABLE
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
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(
COMMAND ${PERL_EXECUTABLE} -v
OUTPUT_VARIABLE PERL_VERSION_OUTPUT_VARIABLE
RESULT_VARIABLE PERL_VERSION_RESULT_VARIABLE
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT PERL_VERSION_RESULT_VARIABLE AND PERL_VERSION_OUTPUT_VARIABLE MATCHES "This is perl.*[ \\(]v([0-9\\._]+)[ \\)]")
set(PERL_VERSION_STRING "${CMAKE_MATCH_1}")
elseif(NOT PERL_VERSION_RESULT_VARIABLE AND PERL_VERSION_OUTPUT_VARIABLE MATCHES "This is perl, version ([0-9\\._]+) +")
set(PERL_VERSION_STRING "${CMAKE_MATCH_1}")
endif()
endif()
endif()
# Deprecated settings for compatibility with CMake1.4
set(PERL ${PERL_EXECUTABLE})
# handle the QUIETLY and REQUIRED arguments and set PERL_FOUND to TRUE if
# all listed variables are TRUE
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Perl
REQUIRED_VARS PERL_EXECUTABLE
VERSION_VAR PERL_VERSION_STRING)
mark_as_advanced(PERL_EXECUTABLE)