[CMake] FindPerlLibs.cmake bug or I don't understand string regex replace

Hugh Sorby h.sorby at auckland.ac.nz
Sun Dec 6 23:40:02 EST 2009


I have been trying to get FindPerlLibs to work on windows (Vista).  It's 
taken me a while but I think I have found the problem.  As far as I have 
been able to identify the string regex replace call returns (what I 
think is) an undesirable result.  Below is an example to illustrate the 
problem:

    SET( TEST_STRING  "test stuff libperl='libperl23.lib'" "\n" )
    string(REGEX REPLACE "libperl='([^']+)'" "\\1" TEST_OUTPUT_VARIABLE 
${TEST_STRING} )
    MESSAGE( STATUS "TEST OUT: (${TEST_OUTPUT_VARIABLE}) 
(${CMAKE_MATCH_0}) (${CMAKE_MATCH_1})" )

where: TEST_STRING is my approximation to the string(s) return from 
${PERL_EXECUTABLE} -V:libperl

The output is:

-- TEST OUT: (test sturff libperl23.lib
) (libperl='libperl23.lib') (libperl23.lib)


So the carriage return is the unexpected bit for me, for the 
TEST_OUTPUT_VARIABLE.  This is why I have put parentheses around the 
variables so that I could see hidden characters.

The attached patch is what I came up with to address the problem, plus 
some other random stuff that I did whilst trying to ascertain what was 
going on.  This is a windows patch so don't try and apply it on Linux.

Also, I took this FindPerlLibs.cmake from the CMake CVS repository 
recently, like today.



-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: FindPerlLibs.cmake.patch
URL: <http://www.cmake.org/pipermail/cmake/attachments/20091207/8a09cb0f/attachment.txt>


More information about the CMake mailing list