ERROR: string sub-command REGEX, mode MATCH needs at least 5 arguments total to command.
OS: Windows 10
cmake --version
cmake version 3.13.1
I'm testing the following function:
set(_docs docs)
function(test_3)
file(STRINGS ${_docs}/_thirdparty.inc lines)
list(LENGTH lines _len)
message("list length: ${_len}") # prints "list length: 267"
list(GET lines 0 _line)
message("line: ${_line}") # prints a line OK
foreach(_line IN LISTS lines)
string(REGEX MATCH "set\\(ZLIB_HOME (.+)\\)" _mm ${_line}) # ERROR thrown
endforeach()
endfunction(test_3)
The error thrown is
CMake Error at cmake/modules/testRegex.cmake:78 (string):
string sub-command REGEX, mode MATCH needs at least 5 arguments total to
command.
Call Stack (most recent call first):
CMakeLists.txt:20 (test_3)
This seems to be a bug i.e. String REGEX MATCH doesn't work inside foreach
loop.
Note that similar REGEX below works fine i.e. when not in a loop
file(READ ${_docs}/_thirdparty.inc file_in)
string(REGEX MATCH "set\\(ZLIB_HOME (.+ZLIB\.Library)\\)" _mm ${file_in})