我正在将一些旧测试转换为 cmake/ctest,并且希望如果输出文件包含特定警告消息,测试就会失败。
过去,我会在输出文件中搜索特定字符串。我已经在使用execute_process 来使用compare_files 命令。是否有类似的命令用于在文件中搜索字符串?
感谢您的帮助。
不,但您可以使用 将该文件读入变量中file。( http://www.cmake.org/cmake/help/v3.0/command/file.html ),然后使用子string命令之一。
file(READ foo TMPTXT)
string(FIND "${TMPTXT}" "needle" matchres)
message(STATUS ${matchres})
if(${matchres} EQUAL -1)
message(FATAL_ERROR "No match found")
endif ()
Run Code Online (Sandbox Code Playgroud)
进而
${CMAKE_COMMAND} -P findmatch.cmake
Run Code Online (Sandbox Code Playgroud)
具体情况可能会有所不同,但总体思路是这样的。
| 归档时间: |
|
| 查看次数: |
3311 次 |
| 最近记录: |