Sanitize linker name to parse implicit link line (#14154)

Teach CMakeParseImplicitLinkInfo to convert the CMAKE_LINKER file name
to a regular expression that matches only the original name.  Escape
special characters like '+' so they are not treated as regex syntax.
Extend the ImplicitLinkInfoTest to test handling of a CMAKE_LINKER value
with many special characters.
This commit is contained in:
Brad King 2013-05-17 08:42:07 -04:00
parent edeabd18e6
commit ffda082e65
2 changed files with 2 additions and 0 deletions

View File

@ -26,6 +26,7 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
set(linker "CMAKE_LINKER-NOTFOUND")
if(CMAKE_LINKER)
get_filename_component(linker ${CMAKE_LINKER} NAME)
string(REGEX REPLACE "([][+.*?()^$])" "\\\\\\1" linker "${linker}")
endif()
# Construct a regex to match linker lines. It must match both the
# whole line and just the command (argv[0]).

View File

@ -508,6 +508,7 @@ list(APPEND platforms msys_g77)
#-----------------------------------------------------------------------------
# Test parsing for all above examples.
set(CMAKE_LINKER "not-a-linker[]().*+^$?")
foreach(p IN LISTS platforms)
cmake_parse_implicit_link_info("${${p}_text}" libs dirs fwks log "${${p}_obj_regex}")