Skip to content

Instantly share code, notes, and snippets.

@rpavlik
Last active October 12, 2016 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpavlik/6ffbcf00d09c94fd756ba7867dd3e3e4 to your computer and use it in GitHub Desktop.
Save rpavlik/6ffbcf00d09c94fd756ba7867dd3e3e4 to your computer and use it in GitHub Desktop.
Somewhat hacky, but semi-functional, way of searching for included CMake modules from a directory.
#!/bin/sh
# first grab the lines that have an include command,
# then filter out the ones where it might be commented out (this might over-filter - can drop this stage)
# then, use sed to grab just the stuff in between () in the include statement
# and finally, sort/uniq.
ag --nofilename 'include[(].*' | \
grep -v '#.*include[(]' | \
sed -r -n 's/.*include[(]([^)]+)[)]/\1/p' | \
sort --unique
#!/bin/sh
# first grab the lines that have an find_package command,
# then filter out the ones where it might be commented out (this might over-filter - can drop this stage)
# then, use sed to grab just the first word in the ()
# and finally, sort/uniq.
ag --nofilename 'find_package[(].*' | \
grep -v '#.*find_package[(]' | \
sed -r -n 's/.*find_package[(]([^) ]+).*/\1/p' | \
sort --unique
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment