2

My editor always generates temp files like #foo.cpp or ~bar.cpp. How to exclude these files from my glob?

file(GLOB_RECURSE SRC_CPP ${PROJECT_SOURCE_DIR} src/*.cpp src/*.cxx)

tom
  • 1,302
  • 1
  • 16
  • 30
  • It is not recommended to glob your source files. Look at this question for details: http://stackoverflow.com/questions/1027247/best-way-to-specify-sourcefiles-in-cmake – David Marquant Jan 08 '16 at 09:08
  • I know the disadvantage. Thanks for reminding. – tom Jan 08 '16 at 10:21

1 Answers1

1

You can specify which characters a file should start with:

file(GLOB FILES [a-z]*.cpp)

This will match only files starting with a-z. If you have files starting with other characters like underscore just add it to the expression:

file(GLOB FILES [_a-z]*.cpp)
David Marquant
  • 2,039
  • 14
  • 12