2016-10-06 58 views
0

我使用cmake 3.7.0-RC1幾個小時前開始,我不知道什麼是錯與SublimeText產生的構建系統,這裏的提供的編譯系統的一個示例:CMake的SublimeText file_regex問題

{ 
    "name": "Project - all", 
    "cmd": ["nmake", "/NOLOGO", "/f", "Makefile", "VERBOSE=1", "all"], 
    "working_dir": "${file_path}", 
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$" 
} 

但使用file_regex不與我的錯誤線在所有的工作,而不是我需要使用類似於此:

{ 
    "name": "Project - all", 
    "cmd": ["nmake", "/NOLOGO", "/f", "Makefile", "VERBOSE=1", "all"], 
    "working_dir": "${file_path}", 
    "file_regex": "^([^(]+)\\((\\d+)\\):\\s*()(.*)$" 
} 

我的錯誤行是這樣的:

D:\sources\personal\python\console\swig_tests\tutorial1\tutorial.cxx(11): error C2065: 'output_value': undeclared identifier 
D:\sources\personal\python\console\swig_tests\tutorial1\tutorial.cxx(13): error C2065: 'output_value': undeclared identifier 
D:\sources\personal\python\console\swig_tests\tutorial1\tutorial.cxx(15): error C2065: 'ret': undeclared identifier 

所以,這是一個衆所周知的問題/錯誤與CMake或我錯過了什麼?

+0

這些看起來像犯錯誤,與ST無關。嘗試使用命令行中的相同參數運行make。我希望你會得到同樣的錯誤。 –

+0

@GerardRoche我想你根本不明白這個問題,請再讀一遍。或者,也許我的英文有點混亂,我的意思是CMake提供的file_regex不會在SublimeText上正確地突出顯示/轉到錯誤行 – BPL

+0

您使用的編譯器是什麼? – arrowd

回答

1

result_file_regex A Perl-style regular expression to capture up to four fields of error information from a results view, namely: filename, line number, column number and error message. Use groups in the pattern to capture this information. The filename field and the line number field are required.

http://docs.sublimetext.info/en/latest/reference/build_systems/configuration.html?highlight=result_file_regex

它說,在文檔「result_file_regex」,但這是錯誤的,因爲重點建設「file_regex」。

下應匹配文件名和行號:

"file_regex": "^([^\(]+)\(([0-9]+)\):.*$" 

的錯誤,不顯示列數。使列號成爲可選:

"file_regex": "^([^\(]+)\(([0-9]+)\):([0-9]+)?.*$" 

添加錯誤消息捕獲組:

"file_regex": "^([^\(]+)\(([0-9]+)\):([0-9]+)? error (.*)$" 

所以下面:

D:\sources\personal\python\console\swig_tests\tutorial1\tutorial.cxx(15): error C2065: 'ret': undeclared identifier 

將匹配:

  • 文件名:D:\sources\personal\python\console\swig_tests\tutorial1\tutorial.cxx
  • 行:15
  • 柱:None
  • 錯誤:C2065: 'ret': undeclared identifier

正則表達式可能會更好,但將所有類似的錯誤信息的工作,就像你出。我希望我已經展示出足夠的適應其他錯誤格式或使其成爲更普遍使用的正則表達式。

+0

這不是CMake中的錯誤嗎?這應該添加到他們的錯誤跟蹤? – usr1234567

+0

非常感謝您的回答,也...什麼@ usr1234567問 – BPL

+0

cmake錯誤不是cmake錯誤。文件'D:\ sources \ personal \ python \ console \ swig_tests \ tutorial1 \ tutorial.cxx'的第11,13和15行中有未聲明的標識符。閱讀cmake未聲明的標識符。 –