tom
tom

Reputation: 1344

How to exclude files from glob with # or ~ at the beginning?

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)

Upvotes: 2

Views: 538

Answers (1)

David Marquant
David Marquant

Reputation: 2237

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)

Upvotes: 1

Related Questions