[Feature Request] Enable the `file(STRINGS ...)` command to process all lines including empty one
As states here: https://cmake.org/cmake/help/v3.14/command/file.html#strings
The file(STRINGS)
command does not have an ability to process all lines including empty one.
I have the code which tries to read a configuration file line-by-line and parse values in a custom format to be able to read environment variables in form like:
CMAKE_CONFIG_TYPES=(Release Debug RelWithDebInfo MinSizeRel) # list variable
ENV_ROOT:WIN:MSVC14::X86="d:/3dparty/vc14_x86"
ENV_ROOT:WIN:MSVC10::X86="d:/3dparty/vc10_x86"
CMAKE_LIBRARY_PATH:UNIX:::X86="/usr/lib/i386-linux-gnu"
LIBLZMA_LIBRARY:WIN:MSVC="$/{ARC_XZ_UTILS_ROOT}/lib/Release/Win32/liblzma/liblzma.lib"
LIBLZMA_LIBRARY:UNIX:GCC::X86="$/{ARC_XZ_UTILS_ROOT}/lib/x86-linux-gnu/liblzma.a"
QT5_ROOT:WIN:MSVC14="c:/Qt/Qt5_11_1/5.11.1/msvc2015"
# has used by default in all configurations
QT5_ROOT:UNIX:GCC::X86="/home/opt/_3dparty/linux_gcc_x86/qt/qt5_10_1/5.10.1/gcc_x86/release"
# overrides a particular configuration
QT5_ROOT:UNIX:GCC:RELEASE:X86="$/{QT5_ROOT}"
QT5_ROOT:UNIX:GCC:DEBUG:X86="/home/opt/_3dparty/linux_gcc_x86/qt/qt5_10_1/5.10.1/gcc_x86/debug"
There is actually a pretty big list and i want to store all variables in one configuration file being able to load it from different interpreter scripts like unix shell or cmake list file.
Currently the main loop in the cmake looks like this:
# with out any filter here to enable to use of the line number to reference it in a parse error
file(STRINGS "${file_path}" file_content)
set(var_file_content_line 0)
foreach(var_line ${file_content})
math(EXPR var_file_content_line "${var_file_content_line}+1")
if(NOT "${var_line}" MATCHES "^[^#\"]+=" OR NOT "${var_line}" MATCHES "([^=]+)=(.*)")
continue()
endif()
... continue parsing here ...
endforeach()
As you can see there is an absolute need to count the lines before start processing a line to output a configuration line number which generated a parse error, so i can't use any filters here in the command. But not either i cannot avoid ignoring empty line.
Can you add a feature for that? Thx!