I'm looking for a regex to match every file begining with a "." in a directory.
I'm using CMake (from CMake doc : "CMake expects regular expressions, not globs") and want to ignore every file begining with a dot (hidden files) BUT "\..*" or "^\..*" doesn't work :(
The strange thing : this works (thanks to rq's answer) and remove every hidden files and temp files ("~" terminated files)
file(GLOB DOT ".*")
file(GLOB TILD "*~")
set (CPACK_SOURCE_IGNORE_FILES "${DOT};${TILD}")
But I can't find the right thing to write directly into CPACK_SOURCE_IGNORE_FILES to have the same result!
Here is the "doc" of this variable.
Sounds like GLOB is probably what you want.
Try this. Open a file "test.cmake" and add the following:
file(GLOB ALL "*")
file(GLOB DOT ".*")
file(GLOB NOTDOT "[^.]*")
message("All Files ${ALL}")
message("Dot files ${DOT}")
message("Not dot files ${NOTDOT}")
Then create a couple of test files:
touch .dotfile
touch notdot
Then run "cmake -P test.cmake". The output is:
All Files /tmp/cmake_test/.dotfile;/tmp/cmake_test/notdot;/tmp/cmake_test/test.cmake
Dot files /tmp/cmake_test/.dotfile
Not dot files /tmp/cmake_test/notdot;/tmp/cmake_test/test.cmake
This was tested with cmake 2.6.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With