1 ############################################################################## 2 # @file FindPerlLibs.cmake 3 # @brief Find Perl libraries. Fixes issue with CMake's default FindPerlLibs. 5 # @sa http://www.cmake.org/pipermail/cmake/2008-July/022638.html 7 # @ingroup CMakeFindModules 8 ############################################################################## 10 #============================================================================= 11 # Copyright 2011-2012 University of Pennsylvania 12 # Copyright 2013-2016 Andreas Schuh <andreas.schuh.84@gmail.com> 14 # Distributed under the OSI-approved BSD License (the "License"); 15 # see accompanying file Copyright.txt for details. 17 # This software is distributed WITHOUT ANY WARRANTY; without even the 18 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 19 # See the License for more information. 20 #============================================================================= 21 # (To distribute this file outside of CMake, substitute the full 22 # License text for the above reference.) 24 # ---------------------------------------------------------------------------- 25 # use CMake's FindPerlLibs.cmake module 31 include (
"${CMAKE_ROOT}/Modules/FindPerlLibs.cmake")
35 unset (PerlLibs_FIND_REQUIRED_BACKUP) 36 unset (PerlLibs_FIND_QUIETLY_BACKUP) 38 # ---------------------------------------------------------------------------- 39 # try to fix any issues 42 COMMAND "${PERL_EXECUTABLE}
" -MConfig -e "print \$Config{version}
" 43 OUTPUT_VARIABLE PERL_OUTPUT 44 RESULT_VARIABLE PERL_RETURN_VALUE 46 if (PERL_RETURN_VALUE EQUAL 0) 47 set (PERL_VERSION_STRING ${PERL_OUTPUT}) 49 if (PERL_VERSION_STRING MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+)
") 50 set (PERL_VERSION_MAJOR "${CMAKE_MATCH_1}
") 51 set (PERL_VERSION_MINOR "${CMAKE_MATCH_2}
") 52 set (PERL_VERSION_PATCH "${CMAKE_MATCH_3}
") 54 message (WARNING "Perl interpreter version
string has unexpected format: ${
PERL_VERSION_STRING}
") 57 # try to fix failure in PERL_INCLUDE_PATH 58 if (PERL_INCLUDE_PATH MATCHES ".*-NOTFOUND
") 60 COMMAND "${PERL_EXECUTABLE}
" -MConfig -e "print \$Config{archlibexp}
" 61 OUTPUT_VARIABLE PERL_OUTPUT 62 RESULT_VARIABLE PERL_RETURN_VALUE 64 if (NOT PERL_RETURN_VALUE) 65 find_path (PERL_INCLUDE_PATH perl.h "${PERL_OUTPUT}/CORE
") 69 # try to fix failure in PERL_LIBRARY 70 IF (PERL_LIBRARY MATCHES ".*-NOTFOUND
") 72 COMMAND "${PERL_EXECUTABLE}
" -MConfig -e "print \$Config{libperl}
" 73 OUTPUT_VARIABLE PERL_OUTPUT 74 RESULT_VARIABLE PERL_RETURN_VALUE 76 if (NOT PERL_RETURN_VALUE) 77 find_library (PERL_LIBRARY NAMES "${PERL_OUTPUT}
" PATHS "${PERL_INCLUDE_PATH}
") 81 # unset local variables 83 unset (PERL_RETURN_VALUE) 86 # ---------------------------------------------------------------------------- 87 # handle the QUIETLY and REQUIRED arguments and set *_FOUND to TRUE 88 # if all listed variables are found or TRUE 89 include (FindPackageHandleStandardArgs) 91 find_package_handle_standard_args ( 100 if (NOT DEFINED PerlLibs_FOUND AND DEFINED PERLLIBS_FOUND) 101 set (PerlLibs_FOUND "${PERLLIBS_FOUND}
") 104 # ---------------------------------------------------------------------------- 105 # map names of variables from upper-case prefix to case-sensitive prefix 107 # This is normally automatically done by CMake BASIS find_package, 108 # but because "PerlLibs
" sets variables also for "Perl
" by *including* 109 # the FindPerl module, we have to do it here explicitly at least for 110 # those variables which are set by the FindPerl module. 111 if (NOT DEFINED Perl_FOUND AND DEFINED PERL_FOUND) 112 set (Perl_FOUND "${PERL_FOUND}
") 116 set (Perl_EXECUTABLE "${PERL_EXECUTABLE}
") 124 set (PerlLibs_LIBRARY "${PERL_LIBRARY}
") 125 set (PerlLibs_INCLUDE_DIR "${PERL_INCLUDE_PATH}
")
cmake PerlLibs_FIND_REQUIRED_BACKUP
cmake PerlLibs_FIND_QUIETLY
cmake PerlLibs_FIND_QUIETLY_BACKUP
cmake PerlLibs_FIND_REQUIRED
cmake PERL_VERSION_STRING