-1

I'm writing a CMakeFile that has the following lines:

configure_file(version.hpp.in version.hpp @ONLY)

file(READ "${CMAKE_CURRENT_BINARY_DIR}/version.hpp" ver)
string(REGEX MATCH "APP_DESCRIPTION ([^\n]*)" _ ${ver})
message("app description: ${APP_DESCRIPTION}")

The version.hpp.in:

#define APP_DESCRIPTION ("this is a demo application")

which will be parsed into version.hpp with the same content.

The output of cmake:

app description: ("this is a demo application")

Although the string(REGEX MATCH "APP_DESCRIPTION ([^\n]*)" _ ${ver}) did exactly what I need it to do, I still don't understand why [^\n]* could work (this line is written by IDE auto-completion).

As my understanding, ^\n means the word starts with a new line character, how is it matching the content in my version.hpp? And why my IDE suggested this line?

Sunderam Dubey
  • 2,294
  • 9
  • 12
  • 22
Qiao
  • 312
  • 3
  • 10

0 Answers0