瀏覽代碼

Merge topic 'implicit-link-sanitize-regex'

ffda082 Sanitize linker name to parse implicit link line (#14154)
Brad King 12 年之前
父節點
當前提交
ad2391b94f
共有 2 個文件被更改,包括 2 次插入0 次删除
  1. 1 0
      Modules/CMakeParseImplicitLinkInfo.cmake
  2. 1 0
      Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in

+ 1 - 0
Modules/CMakeParseImplicitLinkInfo.cmake

@@ -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")
   set(linker "CMAKE_LINKER-NOTFOUND")
   if(CMAKE_LINKER)
   if(CMAKE_LINKER)
     get_filename_component(linker ${CMAKE_LINKER} NAME)
     get_filename_component(linker ${CMAKE_LINKER} NAME)
+    string(REGEX REPLACE "([][+.*?()^$])" "\\\\\\1" linker "${linker}")
   endif()
   endif()
   # Construct a regex to match linker lines.  It must match both the
   # Construct a regex to match linker lines.  It must match both the
   # whole line and just the command (argv[0]).
   # whole line and just the command (argv[0]).

+ 1 - 0
Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in

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